in reply to kill 0 always true

You ask
I've been working with fork(), and kill in an attempt to resolve a problem with a `lynx -source $page` hanging periodically. I thought from various docs that my $result = kill 0, $pid; would tell me if the child process was running or done. But alas the result is always 1. How do I get around this? Claude
perldoc -f kill says:

kill SIGNAL, LIST Sends a signal to a list of processes. Returns the number of processes successfully signaled (which is not necessarily the same as the number actually killed).
$cnt = kill 1, $child1, $child2; kill 9, @goners;
If SIGNAL is zero, no signal is sent to the process. This is a useful way to check that the process is alive and hasn't changed its UID. See the perlport manpage for notes on the portability of this construct.

Unlike in the shell, if SIGNAL is negative, it kills process groups instead of processes. (On System V, a negative *PROCESS* number will also kill process groups, but that's not portable.) That means you usually want to use positive not negative signals. You may also use a signal name in quotes. See the section on "Signals" in the perlipc manpage for details.

so then I perldoc perlport, and it says:

kill SIGNAL, LIST

Not implemented, hence not useful for taint checking. (Mac OS, RISC OS)

kill() doesn't have the semantics of raise(), i.e. it doesn't send a signal to the identified process like it does on Unix platforms. Instead kill($sig, $pid) terminates the process identified by $pid, and makes it exit immediately with exit status $sig. As in Unix, if $sig is 0 and the specified process exists, it returns true without actually terminating it. (Win32)

So now you have to ask yourself what OS you are on?

It would appear your process is not done (i realize you know).

As far as I can see, you can't get around it (it's not quite a zombie). If you're doing any kind of forking, i'd really reccomend Parallel::ForkManager.

Also, check out perlipc and perlfork (if you have it).

This has been an excursion into the world of pod, click here for the friendly guide (If it's got no pod, throw it out -- podmaster).

 
______crazyinsomniac_____________________________
Of all the things I've lost, I miss my mind the most.
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

  • Comment on (crazyinsomniac: pod ) Re: kill 0 always true