in reply to Re: Testing whether a process has finished
in thread Testing whether a process has finished

I explained this to you yesterday! Is there something you didn't understand?
It seems so. I understood from your explanation (which was about killing a process), that after sending the kill signal, the process still resides in the process table and I can't expect that it disappears immediately. So far no problems.

Here we have a different situation, in that it is not about killing a process: I am going to implement a busy wait for a process to end by itself. When the process finishes, I understand that Windows might still take some time to remove the process from the process table, after it is ended - maybe a few seconds, but certainly not minutes, isn't it? So I thought that sooner or later, after sending a kill 0, the process must have disappeared and kill should return 0 (indicating that "it reaches zero processes").

Maybe I really misunderstood what you explained to me yesterday - could you please point out where my understanding is wrong?

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^3: Testing whether a process has finished
by ikegami (Patriarch) on Sep 11, 2009 at 14:26 UTC

    maybe a few seconds, but certainly not minutes, isn't it?

    The process will continue to exist in zombie state until all handles to it are closed. That includes the one the parent has in order to collect the child's exit code.

    That particular handle is closed when you call wait/waitpid. If you don't call wait/waitpid for minutes after the child stopped running, the process is going to be a zombie for minutes.