/* forktest.c Started by Jeff Ondich on 3/26/96 Last modified 9/14/05 This program gives a simple example of fork, and how a process can create a child process. */ #include #include const long limit = 1000000000; const long frequency = 5000000; int main( void ) { long i; if( fork() == 0 ) { /* child */ for( i=0; i < limit; i++ ) { if( i % frequency == 0 ) printf( "I'm the child: %ld\n", i ); } } else { /* parent */ for( i=0; i < limit; i++ ) { if( i % frequency == 0 ) printf( "I'm the parent: %ld\n", i ); } } return( 0 ); }