Question: fork not printing pid, current _ pid and parent _ pid please help #include #include #include #include int main ( ) { pid _ t
fork not printing pid, currentpid and parentpid please help #include
#include
#include
#include
int main
pidt pid;
char message;
int n;
printffork program starting
;
pid fork;
switch pid
case :
perrorfork failed";
exit;
case :
message "This is the child";
n ;
break;
default:
message "This is the parent";
n ;
waitpidpid NULL, ;
break;
for ; n ; n
printfs; pidd; currentpidd; parentpidd;
message, getpidintgetpidintgetppid;
sleep;
exit;
ouput should look like this fork program starting
This is the parent; pid; currentpid; parentpid;
This is the child; pid; currentpid; parentpid;
This is the parent; pid; currentpid; parentpid;
This is the child; pid; currentpid; parentpid;
This is the parent; pid; currentpid; parentpid;
This is the child; pid; currentpid; parentpid;
This is the child; pid; currentpid; parentpid;
$ This is the child; pid; currentpid; parentpid;
Once your output looks similar to what is shown above change the code to include two more children. This may require additional conditionals. Now, one parent and three children should be executing.
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
