exec_same.c 350 B

12345678910111213141516
  1. #include <errno.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. int main(int argc, char** argv, char** envp) {
  6. if (argc > 1) {
  7. puts(argv[1]);
  8. return 0;
  9. }
  10. char* const new_argv[] = {argv[0], "hello from execv process", NULL};
  11. execv(new_argv[0], new_argv);
  12. /* must never reach this */
  13. return 1;
  14. }