I see from the docs that the child process will wait if the object is in a
blocking method(and of course sleep on a remote machine is blocking).  How
can I force the object to immediately die or kill the process even when it
is in a blocking method?  How do people usually do this inside the POE
context?

shutdown<http://search.cpan.org/~gwyn/POE-Component-Generic-0.1205/lib/POE/Component/Generic.pm#___top>

Shut the component down, doing all the magic so that POE may exit. The child
process will exit, causing DESTROY to be called on your object. The child
process will of course wait if the object is in a blocking method.

It is assumed that your object won't prevent the child from exiting. If you
want your object to live longer (say for some long-running activity) please
fork off a grand-child.



On Thu, Aug 19, 2010 at 1:33 PM, Josh803316 <josh803...@gmail.com> wrote:

> I am using poco-generic to spawn a long running child. The child executes a
> series of test steps and then exits when it is finished.  I'm running into a
> problem with attempting to stop/kill the long running child under the
> following condition.
>
> Condition:
> Child process connects to another device (Net::OpenSSH) and executes some
> commands, including some long sleeps on occasion.  For some reason, if I try
> to do the following:   $heap->{$alias}->shutdown();
> While the sleep is active, the spawned child is not killed/doesn't shutdown
> successfully.
>
> Is there another better way to do this:
>
> (Main POE session)
> if($current) {
>  $kernel->sig_child($heap->{$current}->{child_PID}, "sig_child");
> }
>
> (sig_child sub)
> sub sig_child {
> my ($heap, $sig, $pid, $exit_val) = @_[HEAP, ARG0, ARG1, ARG2];
>  my $alias = $heap->{current_alias};
>         # $heap->{$alias} is a reference to the spawned poco-generic
> process
> if(defined $heap->{$alias}){
>  $heap->{$alias}->shutdown();
> my $deleted = delete($heap->{$alias});
>  }
> if(defined $heap->{$pid}){
> my $details = delete $heap->{$pid};
>  }
>  warn "$$: Child $pid exited";
> }
>

Reply via email to