Question: un the following program and identify the pid ( Process ID ) of the parent, child, and grandchild processes. Briefly explain what the program is
un the following program and identify the pid Process ID of the parent,
child, and grandchild processes. Briefly explain what the program is doing. Run and show
output.
#include
#include
#include
int main
pidt pid, pid pid
pidpidpidpid;
fork a child process
pid fork;
if pid
error occurred
fprintfstderr "First Fork
Failed";
return ;
else if pid
child process
pid getppid;
pid getpid;
printfChild PID
d
pid;
printfParent PID
d
pid;
pid fork;
if pid
fprintfstderrSecond
fork failed;
return ;
else if pid
Grandchild process
pidgetpid;
pidgetppid;
printfGrandchild PID
d
pid;
printfChild PID
d
pid;
else
parent process
pid getpid;
pid getppid;
printfParent:
d
pid;
printfRoot:
d
pid;
waitNULL;
return ;
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
