Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 #includeStep 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