:: Re: [DNG] Doing away with multi-thr…
Página Inicial
Delete this message
Reply to this message
Autor: KatolaZ
Data:  
Para: KatolaZ
CC: dng
Assunto: Re: [DNG] Doing away with multi-threading in my project (netman)
On Thu, Sep 03, 2015 at 06:36:39PM +0100, KatolaZ wrote:

[cut]

>
> Sorry guys, I didn't get through the whole thread, but I wanted to say
> just one obvious thing: if your program works correctly, then it is
> *very* difficult (if not impossible) to create and leave zombies
> around. If the program that fork()s does call wait() properly, no
> zombies can remain anywhere. A zombie is just a process which has died
> and is waiting there for its parent to call the damn wait().
>
> If your code leaves zombies, then it is not working properly, and you
> should fix it before moving on.
>


OK, I admit it might had been a tad too cryptic, but my intentions
were good. What I mean is that the parent has to set a handler for
SIGCHLD, and the handler has to call wait() [or waitpid(-1, &status)]
to reap the dead child. The handler must be set *before* any of the
children is ever spawn, otherwise there is still a concrete chance to
create zombies.

If your parent process handles SIGCHLD correctly, you can also force
reaping by sending it a SIGCHLD with the kill command.

My2Cents

KatolaZ


--
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]