Question: a) What is it doing? b) Identify all the system calls c) Indicate what output it will produce to the console d) For each system

a) What is it doing?

b) Identify all the system calls

c) Indicate what output it will produce to the console

d) For each system call, say what it does and how it changes the state of the process if at all.

void main()

{

pid_t pid, mypid;

pid = fork();

if (pid<0) {

printf("Error, fork failed ");

exit(0);

}

else if (pid==0) {

mypid = getpid();

printf("Child process pid is %d ",mypid);

sleep(10);

exit(0);

} else {

mypid=getpid();

wait(NULL);

printf("Parent process pid is %d ",mypid);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!