:: Re: [DNG] BUG: zombies increase whi…
Página Inicial
Delete this message
Reply to this message
Autor: marc
Data:  
Para: Edward Bartolo
CC: dng
Assunto: Re: [DNG] BUG: zombies increase while running netman
> WaitOnExit causes the main thread to wait until the backend finishes.
> This means it will hang the main thread making the GUI irritatingly
> unresponsive. Thus, the only way out is to use multi-threading.


Multithreading is almost always a bad idea, fortunately there
are other options:

Have you considered using waitpid(-1, &status, WNOHANG)
occasionally ?

The proper way is to register a signal handler, set a global
flag in it and do the above at the next convenient time. This can
involve pselect().

while(waidpid(-1, &status, WNOHANG)){
    /* do something with the status - programs can fail, notice that */
}


The manual page for waidpid has the information on how to decode the status.

I do not know how pascal works, and if this is an option there.
But if you have a pipe open to a subordinate process, when it
goes away, the pipe also returns eof, which is the point
at which a wait or waitpid can collect the status.

> Regarding zombies, these were automatically adopted by the frontend as
> terminating the latter also reaped all of them.


Almost: They were then adopted by init, which did the wait and then
the zombie process table entries could be cleared.

regards

marc