Question: Using the following program, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent
Using the following program, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 2600 and 2603, respectively. getpid() function returns the pid of the current process.) #include #include #include int main() pid_ t pid, pidl; * fork a child process */ pid = fork(); if (pid < 0) { * error occurred */ fprintf(stderr, "Fork Failed"); return 1; else if (pid =0) { * child process */ pidl = getpid(); printf"child: pid = %d",pid); /* A / printf"child: pidl = %d",pid1); /* B */ else { /* parent process */ pidl = getpid(); printf "parent: pid = %d",pid); /* C/ printf"parent: pid1 = %d",pid1); /*D*/ wait(NULL); return 0;
Step by Step Solution
3.65 Rating (163 Votes )
There are 3 Steps involved in it
Problem 1 value of pid at A is 0 At A the code block has ... View full answer
Get step-by-step solutions from verified subject matter experts
