Question: Modify the program in Figure 8 . 1 8 so that the following two conditions are met: 1 . Each child terminates abnormally after attempting
Modify the program in Figure so that the following two conditions are met:
Each child terminates abnormally after attempting to write to a location in the readonly text segment.
The parent prints output that is identical except for the PIDs to the following: child terminated by signal : Segmentation fault child terminated by signal : Segmentation fault
Figure
#include "csapp.h
#define N
int main
int status, i;
pidt pid;
Parent creates N children
for i ; i N; i
if pid Fork child
exiti;
Parent reaps N children in no particular order
while pid waitpid &status,
if WIFEXITEDstatus
printfchild d terminated normally with exit statusd
pid, WEXITSTATUSstatus;
else
printfchild d terminated abnormally
pid;
The normal termination is if there are no more children
if errno ECHILD
unixerrorwaitpid error";
exit;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
