Question: Here is pids2.c And here is pids3.c Do this question in linux Program pids 3.c is a copy of pids2.c but with all the sleep

Here is pids2.c

And here is pids3.c

Do this question in linux
Program pids 3.c is a copy of pids2.c but with all the sleep commands removed. Compile and run. If you run it enough times, you will notice it usually behaves like pidsi (child gets correct parent pid), but sometimes it behaves like pids2 (child thinks its parent's pid is 1). It is unpredictable. why? Note: if you want to see this more clearly, try running pids3 over and over, in a loop, and each time only keep the output lines that end in "1". e.g., try copying-and-pasting this into your shell window: while [ 1 ] ; do pids 31 grep child | grep "1$" done more This will show you that sometimes child gets "1" as parent pid, and sometimes it gets its "birth-parent"'s pid. **NOTE** You may need to ctrl-c a couple of times to stop the while loop. #define _GNU_SOURCE //for Ubuntu #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
