In UNIX or its similar OS environment if a process stops
running abnormally but its entry has not removed from process table known as
Zombie Process.
Reason
If a process gets stop with exit and meanwhile parent
process is sleeping then parent will be able to known the status at sleeping
moment and entry of the killed process still in process table which imply Zombie.
Solution
When a Zombie is got created parent Update itself by read
all its child status to exit and update the process table. This process is
known as “reaps “
Example
// A C program
to demonstrate Zombie Process.
// Child becomes
Zombie as parent is sleeping
// when child
process exits.
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int
main()
{
// Fork returns
process id
// in parent
process
pid_t child_process_id = fork();
// Parent process
if
(child_process_id > 0)
sleep(50);
// Child process
else
exit(0);
return 0;
}
No comments:
Post a Comment