Question: Zombie process A zombie process in system programming refers to a process that has completed execution but still has an entry in the process table.
Zombie process
A zombie process in system programming refers to a process that has completed execution but still has an entry in the process table.
This happens when the parent process hasn't yet read the exit status of the child process via wait or waitpid system calls Here
are the key points about zombie processes:
State: The process is in a "terminated" state but is not fully removed from the system as its parent process hasn't called wait to
collect its exit status. This state is called Z zombie in UnixLinux systems.
Parent Process Role:
The parent process is responsible for calling wait or waitpid to retrieve the termination status of its child.
If the parent process doesnt call these functions, the child remains in the zombie state.
If you run the ps command before the parent gets terminated the output of ps will show the entry of a zombie processdenoted by
defunct This happens because the child is no longer active but its exit code needs to be stored in case the parent subsequently calls
wait.
Zombie Process
zombiec
#include
#include
int main
pidt t;
tfork;
ift
printfChild having id d
getpid;
else
printfParent having id d
getpid;
sleep; Parent sleeps. Run the ps command during this time
Lab exercise
Q Create a scenario where a parent has two child process C and C
such that C becomes a zombie while C becomes an orphan process.
give me the code for this question.
follow the above concept. and give me the clear code and output explanation.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
