Question: fork int x; int main ( int argc, char * argv [ ] ) { pid _ t pid 1 , pid 2 ; int
fork
int x; int mainint argc, char argv
pidt pid pid;
int y;
x atoiargv;
y atoiargv;
pid fork;
if pid
fprintfstderr "Fork Failed";
return ;
else if pid
x ;
y ;
pid getpid;
printfd
pid; A:
printfd
pid; B
printfd d
x y; C
else
x ;
y ;
pid getpid;
waitNULL;
printfd
pid; D
printfd
pid; E
printfd d
x y; F
return ;
We consider the above program for the question at the right side: The above program takes two input arguments and assigns them to x and y respectively. We consider one instance: x is initialized as and y is initialized as We also assume that the actual pids of the parent and child are and respectively. Identify the values at Lines B C D E and F by running the program:
B: pid
C: x
y
D: pid
E: pid
F: x
y
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
