Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started