script.c 375 B

1234567891011121314151617
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <errno.h>
  4. #include <unistd.h>
  5. int main (int argc, const char ** argv, const char ** envp)
  6. {
  7. int newfd = dup(1);
  8. char fd_argv[4];
  9. snprintf(fd_argv, 4, "%d", newfd);
  10. char * const new_argv[] = { "./script1.sh", fd_argv, NULL };
  11. setenv("IN_EXECVE", "1", 1);
  12. execv(new_argv[0], new_argv);
  13. return 0;
  14. }