#include #include #include main(int argc, char *argv[]) { int pid; printf("Single\n"); pid = fork(); if (pid < 0) { perror("fork failed"); exit(-1); } /* child */ else if (pid == 0) { printf(" Child Process\n"); printf(" Executing %s using execvp ...\n",argv[1]); execvp(argv[1], &argv[1]); /* see man execvp */ /* If execvp returns, the call has failed */ perror("execvp failed to run"); exit(-1); } /* parent */ else { wait( (int *)0 ); /* wait to avoid child zombie */ printf("Parent Process\n"); printf("--my child has completed the %s\n",argv[1]); exit(0); } }