Programming and posix - April 2002

April 3, 2002
Solution Symposium
Page 40
hp e3000
programming
and posix
process management - fork() - 1
#include <unistd.h>
if ( (pid = fork()) < 0) { /* error */
perror("fork");
} else if (pid == 0) { /* child */
printf("child: here\n");
} else { /* if pid > 0 */ /* parent */
printf("parent: here\n");
}
clones the current process, creating an identical child
with the exact same run-time state (open files, stack
trace, local variable values, etc)