}
for(i = 1; i < 4; i++) if (wait(0) == -1) {
perror("Error in wait"); return 1;
>
return 0;
3. (10 p.) You are given a program:
int main ()
{
pid_t pid; int i;
for (i = 4; 1++)-
switpłf^Cpid = fork()) { case -1:
perror("Error in fork"); return 1; case 0:
execlp("pwd","pwd",0); perror("Error in execM); exit(1) ; default:
printf("pid = %d", pid);
>
Mark correct answers (correct answer is worth +2p, while incorrect answer yields
—2p.
(a) The program creates:
i. a linę of processes (father, son, grandson etc.),
ii. a bunch of processes (father and a number of sons),
iii. a treę of processes,
iv. one ęhild process.
(b) The program creates:
i. /l child process,
ii. 3 child processes,
iii. 4 child processes,
iv. 7 child processes.
(c) Can there appear zombies?
i. Yes
ii. No
(d) Which processes output their identi-fiers?
i. the parent process,
ii. the child process(es),
iii. both,
iv. nonę.
(e) The parent process:
i. does not wait for the termina-tion of its children,
ii. waits for the termination of all its children,
iii. waits for the termination of one child (but not all).