Warum gibt es Zombie-Prozesse?
Wikipedia sagt: "Ein untergeordneter Prozess, der abgebrochen wird, von seinen Eltern aber nie abgewartet wird, wird zu einem Zombie-Prozess." Ich führe dieses Programm aus:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main()
{
pid_t pid, ppid;
printf("Hello World1\n");
pid=fork();
if(pid==0)
{
exit(0);
}
else
{
while(1)
{
printf("I am the parent\n");
printf("The PID of parent is %d\n",getpid());
printf("The PID of parent of parent is %d\n",getppid());
sleep(2);
}
}
}
Dadurch wird ein Zombie-Prozess erstellt, aber ich kann nicht verstehen, warum hier ein Zombie-Prozess erstellt wird.
Die Ausgabe des Programms ist
Hello World1
I am the parent
The PID of parent is 3267
The PID of parent of parent is 2456
I am the parent
The PID of parent is 3267
The PID of parent of parent is 2456
I am the parent
....
.....
Aber warum wird in diesem Fall der "untergeordnete Prozess beendet, aber nicht von seinem übergeordneten Prozess abgewartet"?