Re: poe wheel run question (sending the signal to the process group id instead of PID)

"Chris 'BinGOs' Williams" <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
On Mon, Mar 02, 2009 at 11:47:09AM +0100, jorge sanchez wrote:
> Hi list,
> 
> I have one question regarding the POE::Wheel::Run kill method,
> according to the cpan.org page this method delivers signal to the
> child process.
> We are using the POE::Wheel::Run to spawn child which then spawns
> another childs in the chain. We also are using sort of watchdog timer
> which sends SIGKILL  signal to the child if it takes too long to
> accomplish its task to take it down.
> 
> The problem is that if we kill the child which has spawn other childs
> and if we send SIGKILL signal to this child then the spawned childs
> are reaped by init and are there  outside of our controll.
> 
> It would be very convenient to have also method to send the signal to
> the process group id to take down all the processes within the same
> process group.

Since version 1.0001 of POE, POE::Wheel::Run will use setpgrp() to change
the process group of the spawned process ( but only if the Conduit type isn't
'Pty' or 'Pty-pipe' which uses setsid() to change the process group ).

POE::Wheel::Run's kill() method basically uses perl's kill function under
the hood so the advice from there stands (http://p3rl.org/kill).

"Unlike in the shell, if SIGNAL is negative, it kills process groups instead of processes"

$wheel->kill(9); # Send KILL signal to the wheel PID

$wheel->kill(-9); # Send KILL signal to the wheel process group.

On SystemV (like Solaris) you can also use negative process IDs

kill( 9, $wheel->PID ); # Send KILL signal to the wheel PID

kill( 9, '-' . $wheel->PID ); # Send KILL signal to the wheel process group.

With the caveat from 'kill' documentation:

"(On System V, a negative PROCESS number will also kill process groups, 
but that's not portable.)"

Cheers,

-- 
Chris Williams
aka BinGOs
PGP ID 0x4658671F
http://www.gumbynet.org.uk
==========================
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFJq8R27eyMi0ZYZx8RAs+AAJ9pSas0sFZyd5e7/voE6lGkXoGwVwCfeF/e
vK++dmBT9z6t+79A2YZB8MU=
=M+wl
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.