/* * ISA 563, Spring 2011 * Copyleft by Muhammad Abdulla */ #include #include #include #include /* * fork.c -- demonstrate the fork system call. */ int main ( int argc, char *argv[] ) { int pid; pid = fork(); if ( pid < 0 ) { // error condition fprintf(stderr, "Could not fork!\n"); exit(-1); } else if ( pid == 0 ) { // child process fprintf(stdout, "Inside child, pid = %d\n", getpid()); } else { // parent process fprintf(stdout, "Inside parent, child pid is = %d\n", pid); } return 0; }