Where do zombie processes take place after the death of their parents?

A Zombie process is a process that has completed execution, but still has an entry in the process table (the parent did not read its exit code, or, in other words, it was not “received”).

An orphan process is a process whose parent has finished, although he continues to work on his own (his parent “passed away”, but he is still “alive”). in this case he initwill accept him and will wait for him.

So, consider the following:

int main(int argv, char *argc[]) {

    pid_t p=fork();

    if (p<0) {
        perror("fork");
    }

    // child
    if (p==0) {
        exit(2);
    }

    // parent sleeps for 2 seconds
    sleep(2);
    return 1;
}

The baby process created here will be a zombie in 2 seconds, but what will be its status when the parent finishes? Zombie orphan?

What happens with his entry into the process table?

Are "zombie orphans" (for example, above) also accepted initand received by him?

+4
1

man 2 wait:

, , , " ". - (PID, , ) , . , , , . , "" ( ) init (8), .

, ( ) init. , , init wait() .

, , " " - .

+5

Source: https://habr.com/ru/post/1545514/


All Articles