/* Demonstrate vfork. Note that the parent now sleeps until */ /* the exec call terminates, waiting for the execed process to */ /* terminate. */ /* Sample calls (executable named waitdemo): */ /* waitdemo ls -l | more */ /* waitdemo cat testvfork.c */ #include #include #include main(argc,argv) int argc; char *argv[]; {FILE *fp; pid_t IsParent; IsParent=vfork(); if (IsParent) { wait(NULL); fprintf(stdout,"Parent Returns!\n"); /* Don't need to flush. stderr is also not buffered */ } else { execvp(argv[1],argv+1); } }