#include #include #include #include int main() { int mypid = getpid(); int mykid; printf("%d: About to fork...\n",mypid); fflush(NULL); mykid = fork(); if(mykid == 0) { // Child process path int mypid = getpid(); int myparent = getppid(); printf(" %d: This is child process %d of parent %d\n",mypid,mypid,myparent); fflush(NULL); exit(12); } int status; waitpid(mykid, &status, 0); printf("%d: Okay, child process %d has finished with exit code %d\n",mypid,mykid,WEXITSTATUS(status)); }