:: Re: [DNG] Reaping orphan processes.
Startseite
Nachricht löschen
Nachricht beantworten
Autor: Didier Kryn
Datum:  
To: dng
Betreff: Re: [DNG] Reaping orphan processes.
Le 04/03/2023 à 18:44, Hendrik Boom a écrit :
> One thing I've always wondered about.
> Why is it necessary to reap orphan processes?
> Why can't they just terminate by themselves?
>

    There are two reasons at least why zombies must be reaped:

    1) every process, even orphanned, occupies some space in RAM

    2) the whole range of process IDs will be used after some time,
making it impossible to give an ID to a new process, therefore making it
impossible to create new processes. Only once a zombie process has been
reaped, its pid is made available again.

    Processes don't vanish when they terminate because the possibility
must be given to examine the way they terminate, their exit code. The
exit code tells wether the process has detected an eror or has been
killed by a signal. This is the way the interactive shell, for example,
reports command failures: the shell reaps the terminated process,
examines its exit status and reports errors to the terminal. Every
process is responsible of reaping its children processes. If the parent
process dies before the child, this one is called an orphan, as you
would expect, and pid1 can and should reap it. When a process
terminates, its parent, or pid1, receives the SIGCHLD signal. There is
also a concept of subreaper which can slightly complicate this picture.

    See 'man 2 wait' for more details.

--     Didier