Pardus has asked for the wisdom of the Perl Monks concerning the following question:

The following question was also posted to usenet's comp.lang.perl.misc, sorry for the duplication, but I really need some input on this.

While checking the syntax of the kill() function I noticed a difference between the perlipc and the perlfunc manual pages . It regards the way to kill a process group.

quoting perlipc (item "Signals"):
# Sending a signal to a negative process ID means that you
# send the signal to the entire Unix process-group.
Also all examples in perlipc seem to advocate this as the default way to do this.
quoting perlfunc (item "kill"):
# 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.)

Does this mean the things described in perlipc only work on SysV and are not portable? if so how does this work on my linux box? Has there been a syntax change for the kill() function and is one of both pages not up2date? Or is one of both pages plain wrong!??

Also if using signal 0 (zero) to poll processes how do you poll the group with a negative signal!?

Please enlighten me

--
Jaap Karssenberg || Pardus (Larus)? <pardus@cpan.org>
>>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<

Replies are listed 'Best First'.
Re: kill(9, -9) or kill(-9, 9) ?
by neuroball (Pilgrim) on Jan 10, 2004 at 20:39 UTC

    Just by reading both manual slices in perldoc I found out that SysV is killing the process groups and also the processes. Whereby every other OS is just killing the process groups.

    Yet you might want to build a test case and walk through it on as many OSs as possible.

    So... are you able to kill process groups cross-platform? I would say so. You just aren't able to kill the groups AND the processes. I.e. you might have to kill those seperately.

    One more thing for you to read would be perldoc perlport which specifies the following golden morsel: Don't count on signals or %SIG for anything..

    Could you give us some info on what you try to archive, so that we could give you a bit more constructive help?

    /oliver/

      I'm trying to do a complete implementation of a shell with job-control in pure perl, see http://zoidberg.sf.net.

      Currently the SysV method seems to work (on linux that is) except for some dark and obscure bugs, I was hoping that by coming to understand all the hidden features of kill() I could uncover some of these bugs.

      --
      Jaap Karssenberg || Pardus (Larus)? <pardus@cpan.org>
      >>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<
Re: kill(9, -9) or kill(-9, 9) ?
by ysth (Canon) on Jan 11, 2004 at 06:27 UTC
    Also if using signal 0 (zero) to poll processes how do you poll the group with a negative signal!?
    I was going to suggest killpg() instead, but there are two problems with that: first, POSIX.pm doesn't have it (though it probably should, where available); second, SUSv3 documents killpg(pgrp, sig) as being the same as kill(-pgrp, sig) when sig is > 1 and undefined otherwise.

    That leads me to suspect that polling a process group is considered an unuseful feature. What would it mean?