On Tue, 06 Apr 2010, Octavian Rasnita wrote:
> No, it returns 1 for the processes that just ended (but a pretty long
> time after those processes were killed).

Note that there is no guarantee that the PID will become invalid just
because the process enters the INACTIVE stage.  The PID will remain
valid until *all* handles to this process have been closed.  So it
is not enough to just kill the process; whatever parent has started
it must make sure it hasn't kept any references to it either.  So
how exactly are you starting the process?

If you look at the POSIX definition of kill() you'll read that it
explicitly mentions that process lifetime covers the inactive
phase as well:

| In particular, this means that an application cannot have a parent
| process check for termination of a particular child with kill().

You can use Win32::Process to check if the process is still running
or not though (warning, untested code):

    require Win32::Process;
    Win32::Process::Open(my $process, $pid, 0);
    Win32::Process::GetExitCode(my $exitcode);
    if ($exitcode == Win32::Process::STILL_ACTIVE()) {
        # still running
    }
    else {
        # zombie waiting to be reaped
    }

Cheers,
-Jan


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to