script.c 369 B

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