Question: Figure 8.18 is the picture with the code Section 8.4 Process Control 749 1 #include csapp.h 2 #define N2 codelecf/waitpid2.c 4 int main() int status,
Section 8.4 Process Control 749 1 #include "csapp.h" 2 #define N2 codelecf/waitpid2.c 4 int main() int status, i; pid.t pid[N], retpid; /* Parent creates N children / for (i = 0; o) 15 16 17 18 19 (WIFEXITED (status)) printf( "child if %d terminated normally with exit status:%d ", retpid, WEXITSTATUS (status)); 20 21 else printf ( "child %d terminated abnormally ", retpid); 23 * The only normal termination is if there are no more children / if (errnoECHILD) 25 unix_error("waitpid error") exit (0); 29 ndelecfwaitnid?e 8.24 odify the program in Figure 8.18 so that the following two conditions are met Each child terminates abnormally after attempting to write to a location in the read-only text segment. . The parent prints output that is identical (except for the PIDs) to the fol lowing: child 12255 terminated by signal 11: Segmentation fault child 12254 terminated by signal 11: Segmentation fault Hint: Read the man page for psignal(3)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
