Question: #include . . . > int value = 5 ; int main ( ) { pid _ t pid; pid = fork ( ) ;

#include ...>
int value =5;
int main()
{
pid_t pid;
pid = fork ();
if (pid 0){
printf ("failed to fork a new process.
");
exit (1);
}
value +=15;
printf("pid=%d, value =%d
", pid, value);
}
The above C program creates a child process using the system call fork (). If the child
process is created successfully, (1) what will be the output? (Assume the pid of the
newly-created child process is 1000)(2) How many lines will the program (both
parent and child processes) print? If your answer is one line, then skip the next
question. Otherwise, continue. (3) If we want to print the message line ONLY from
the parent process (not the child process), how will you modify the program?
#include < . . . > int value = 5 ; int main ( ) {

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 Programming Questions!