Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

This is cloneProcess.c given below

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago