
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

CS 2204 Lab 12
your name here (please print):
your student ID number here:
Create a subdirectory called lab12 under your home directory. Perform any necessary work for this lab assignment in that directory. Ensure that this assignment is performed from within a bash shell. Revisit the lecture notes of Nov 14 in preparation for this lab assignment.
#include <stdio.h> main () { int pid; int i;
for (i=0; i<3; i++){ if ((pid=fork()) <0) { printf("Sorry, cannot fork\n"); } else if (pid == 0) { printf("child %d\n", i); } else { printf("parent %d\n", i);}} exit(0); }
How many processes are involved, in total, in this program? Hint: Merely analyzing the output of the program will not help you. You need to understand exactly how the fork() system call works.