An Example Using fork()
main(int argc, char *argv[]) {
char *myName = argv[1];
int cpid = fork();
if(cpid == 0) {
printf(“The child of %s is %d\n”,
myName, getpid());
exit(0);
} else {
printf(“My child is %d\n”, cpid);
exit(0);
}
Previous slide
Next slide
Back to first slide
View graphic version