Question: This is cloneProcess.c given below The two pictures below are all cloneProcess.c Run cloneProcess Your output should be (except for pids): The variable was: 9

 This is cloneProcess.c given below The two pictures below are all

This is cloneProcess.c given below

cloneProcess.c Run cloneProcess Your output should be (except for pids): The variable

was: 9 Part after clone has pid 10992 I am 10993 and

The two pictures below are all cloneProcess.c

Run cloneProcess Your output should be (except for pids): The variable was: 9 Part after clone has pid 10992 I am 10993 and my parent is 10992 The variable is now: 9 Read from the file: a Explain why the file closure and the variable modification are not recognized (variable has old value, and file still open). #define GNU_SOURCE //for Ubuntu #include #include #include #include #include #include #include int variable, fd; int do something() { variable 42; close(fd); printf("I am %d and my parent is %d ", getpid(), getppid()); exit(0); } int main(int argc, char *argv[]) { const int STACK_SIZE = 65536; /ote stack grows down char *stack; char *stacktop; char tempch; int cret; stack = malloc(STACK_SIZE); if (stack NULL) { perror("malloc"); exit(1); } stackTop = stack + STACK_SIZE; /* Assume stack grows downward */ 9; variable fd = open("test.file", O_RDONLY); if (fd -1) { fprintf(stderr, "To run this, you need a file named test.file in this directory!! "); exit(2); } printf("The variable was: %d ", variable); cret=clone (do_something, stackTop, O, NULL); if (cret==-1) {perror("clone"); exit(0); } //parent keeps going here printf("Part after clone has pid %d ",getpid()); sleep(1); printf("The variable is now: %d ", variable); if (read(fd, &tempch, 1)

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!