Question: Problem 1 ( 1 0 points ) In class, we used two C programs to show regualar.c: - A parent creates a child process, waits

Problem 1(10 points)
In class, we used two C programs to show
regualar.c: - A parent creates a child process, waits for the child to complete, then exits.
zombie.c: - A parent creates a child process then goes to sleep without waiting for the
child to complete.
The child exits while its parent is sleeping and becomes a "zombie".
When the parent exits, the child process is re-parented by init, which
cleans up the zombie process automatically.
Create a new C program orphan. c where a parent creates a child, exits before the child completes (hint:
you may put the parent into sleep for a short period of time; meanwhile, also put the child into sleep for a
period of time that is longer than parent), leaving it an "orphan" process. The orphan is re-parented by
init and exits eventually.
Make sure your C program compiles and runs. The following is a sample of what the program is supposed
to output:
/a4 $ gcc orphan.c -o orphan
a4$./orphan
(parent): Parent's PID : 3947
(child): Child's PID : 3948
(child): Child's Parent ID : 3947
(parent): Parent exits. Child becomes an orphan
./a4 $
(child): Orphan Child's Parent ID : 1(init). Orphan is re-parented.
(child): Orphan Child exits.
./ a 4 $
 Problem 1(10 points) In class, we used two C programs to

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!