/*-------------------------------------------------------------------*/ /* testfork.c */ /* The fork system call. */ /*-------------------------------------------------------------------*/ #include #include int main(int argc, char *argv[]) { printf("Beginning of process %d.\n", getpid()); printf("Before fork in process %d.\n", getpid()); fork(); printf("After fork in process %d.\n", getpid()); printf("End of process %d.\n", getpid()); return 0; } /* Sample executions: $ testfork Beginning of process 20548. Before fork in process 20548. After fork in process 20548. After fork in process 20549. End of process 20548. End of process 20549. $ testfork Beginning of process 20550. Before fork in process 20550. After fork in process 20550. End of process 20550. After fork in process 20551. End of process 20551. $ testfork Beginning of process 20552. Before fork in process 20552. After fork in process 20553. End of process 20553. After fork in process 20552. End of process 20552. $ */