/* fork2.c Started by Jeff Ondich on 3/26/96 Last modified 3/26/96 This program gives a simple example of exec, and how a parent process can wait for a child process to return. */ #include void main() { long status, pid; /* Create the new process. */ pid = fork(); if( pid != 0 ) /* Parent */ { printf( "Parent just created child, ID %d\n", pid ); fflush( stdout ); pid = wait( &status ); printf( "Child ID %d just exited with status %d\n", pid, status>>8 ); fflush( stdout ); } else /* Child */ { printf( "Process %d is about to execute 'getanumber'\n", getpid() ); fflush( stdout ); execlp( "getanumber", "dog", "cat", "kudu", (char *) 0 ); printf( "Will this get printed? No.\n" ); fflush( stdout ); } }