/*-------------------------------------------------------------------*/ /* testfork.c */ /* The fork system call. */ /*-------------------------------------------------------------------*/ #include #include int main(int argc, char *argv[]) { int iRet; printf("Parent process (%ld)\n", (long)getpid()); fflush(NULL); iRet = fork(); if (iRet == -1) {perror(argv[0]); return 1; } printf("Parent and child processes (%ld)\n", (long)getpid()); return 0; } /* Sample executions: --> gcc -Wall -ansi -pedantic -o testfork testfork.c --> testfork Parent process (99) Parent and child processes (99) Parent and child processes (100) --> testfork Parent process (112) Parent and child processes (112) Parent and child processes (113) --> */