Question: give me the code for the TODO section: / / TEMPLATE / / fork _ me . c: a deceptive pattern of forking #include #include
give me the code for the TODO section:
TEMPLATE
forkmec: a deceptive pattern of forking
#include
#include
#include uncomment if using wait waitpid system call
int globaltotal ;
int mainvoid
printfSTART pid: d parentpid: d
getpidgetppid;
fflushstdout; flush stdout to preven IO duplication
int depth ;
forint i; i; i
globaltotal;
pidt child fork;
ifchild
depth;
break;
TODO: insert code that makes parent pause until child is
finished, extracts its exit code, and adds that exit code onto
the globaltotal in this parent
forint i; i
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
