Question: Linux question with c programs Copy file fork_mpm.c into a file named clone_mpmProcess.c Modify clone_mpmProcess.c so that it accomplishes the same thing, but by using

Linux question with c programs

Copy file fork_mpm.c into a file named clone_mpmProcess.c Modify clone_mpmProcess.c so that it accomplishes the same thing, but by using clone instead of fork. Your output should be (except for pids): > clone_mpmProcess

This is process(thread) 11501. x+y=1 > This is process(thread) 11502. x+y=7

fork_mpm.c

#include #include #include

int main ( void ) { int x = 0, y = 0; pid_t pid, fpid;

fpid = fork (); pid = getpid();

if (fpid > 0) { printf (" This is process (thread) %d. ", pid); y = 1; } else if (fpid == 0){ sleep(1); printf (" This is process(thread) %d. ", pid); x = 7; } else { printf ("fork failed "); return (1); }

printf("x+y=%d ", x + y); }

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!