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

2009-03-02 Thread Chris 'BinGOs' Williams
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
==


pgpOJXmwg49fG.pgp
Description: PGP signature


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

2009-03-02 Thread jorge sanchez
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.

Regards,

Jorge Sanchez