in reply to Re: Killing a Forked Subprocess
in thread Killing a Forked Subprocess

I think 15 is SIGTERM. please confirm on your system

Just use symbolic names for signals and don't worry about numbers:

kill 'SIGTERM', getpgrp( $child_pid );

--
Ilya Martynov (http://martynov.org/)

Replies are listed 'Best First'.
Re: Re: Re: Killing a Forked Subprocess
by lestrrat (Deacon) on Mar 21, 2002 at 20:32 UTC

    Wouldn't the symbolic name be 'TERM', not 'SIGTERM' ? And also, since you're sending the signal to a process group, don't you need to give it a negative signal value?

    =item kill LIST Sends a signal to a list of processes. The first element of the list must be the signal to send. Returns the number of processes successfully signaled. $cnt = kill 1, $child1, $child2; kill 9, @goners; Unlike in the shell, in Perl if the I<SIGNAL> is negative, it kills process groups instead of processes. (On System V, a negative I<PROCE +SS> 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 L<perlipc/"Signals"> for details.
      Wouldn't the symbolic name be 'TERM', not 'SIGTERM'?

      I've just tested it. Actually both of them work. At least on perl 5.6.1.

      And also, since you're sending the signal to a process group, don't you need to give it a negative signal value?

      Oops. I'm sorry, I missed that. I don't know if it is allowed to write kill '-SIGHUP', .... If not still constants from POSIX.pm can be used instead of numbers:

      use POSIX qw(SIGHUP); kill -(SIGHUP), ....;

      --
      Ilya Martynov (http://martynov.org/)