script.c 395 B

1234567891011121314151617
  1. #define _XOPEN_SOURCE 700
  2. #include <errno.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <unistd.h>
  6. int main(int argc, const char** argv, const char** envp) {
  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 1;
  14. }