/* * Sample program for wait() system call - No. 7 * * wait, waitpid(2) - wait for process termination * * Synopsis * #include * #include * * pid_t wait(int *status); * pid_t waitpid(pid_t pid, int *status, int options); */ #include #include #include main() { int i; fork(); wait(NULL); /* wait for child process termination */ for (i = 0; i < 3; i++) { printf("PID = %d i = %d\n", getpid(), i); sleep(1); } }