Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Using the program in below, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 1200 and...

Using the program in below, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 1200 and 1203, respectively.)

#include <sys/types.h>

#include <stdio.h>

#include <unistd.h>

int main()

{

pid_t pid, pid1;

/* fork a child process */

pid = fork();

if (pid < 0) {

fprintf(stderr, "Failed");

return 1;

}

else if (pid == 0)

pid1 = getpid();

printf("child: pid = %d", pid); /* A */

printf("child: pid1 = %d", pid1); /* B */

}

else

pid1 = getpid();

printf("parent: pid = %d", pid); /* C */

printf("parent: pid1 = %d", pid1); /* D */

wait(NULL);

}

Return 0;

}

Ans)

A =

B =

C =

D =

Why?

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question