/*********************************************************** * * env_exec.c * * 4/15/02 Jeff Ondich * * Illustrates environment variables after a fork and * exec. * **********************************************************/ #include #include #include #include #include int main() { int status; pid_t pid; /* Create the new process. */ pid = fork(); /* Parent */ if( pid != 0 ) { printf( "Parent just created child, ID %d\n", pid ); fflush( stdout ); pid = wait( &status ); printf( "My child ID %d just exited with status %d\n", pid, WEXITSTATUS(status) ); fflush( stdout ); } /* Child */ else { printf( "Process %d is about to execute 'environment'\n", getpid() ); fflush( stdout ); execlp( "environment", (char *) 0 ); } return( 0 ); }