in reply to IPC::Run and start(); pump(); finish()

the IPC::Run->signal() function seems to be able to grab the pid:
sub signal { my IPC::Run $self = shift ; local $cur_self = $self ; $self->_kill_kill_kill_pussycat_kill unless @_ ; Carp::cluck "Ignoring extra parameters passed to kill()" if @_ > 1 +; my ( $signal ) = @_ ; croak "Undefined signal passed to signal" unless defined $signal ; for ( grep $_->{PID} && ! defined $_->{RESULT}, @{$self->{KIDS}} ) +{ _debug "sending $signal to $_->{PID}" if _debugging; kill $signal, $_->{PID} or _debugging && _debug "$! sending $signal to $_->{PID}" ; } return ; }
However, I'm not sure how (or if) I can do the same thing from my script...im afraid i may have to modify the module itself, and even then im not totally sure what to do.

Replies are listed 'Best First'.
Re^2: IPC::Run and start(); pump(); finish()
by BrowserUk (Patriarch) on Nov 14, 2005 at 17:27 UTC

    I think I would be tempted to try modifying IPC::Run->signal() to return the result of kill:

    sub signal { my IPC::Run $self = shift ; local $cur_self = $self ; $self->_kill_kill_kill_pussycat_kill unless @_ ; Carp::cluck "Ignoring extra parameters passed to kill()" if @_ > 1 +; my ( $signal ) = @_ ; my $rv; croak "Undefined signal passed to signal" unless defined $signal ; for ( grep $_->{PID} && ! defined $_->{RESULT}, @{$self->{KIDS}} ) +{ _debug "sending $signal to $_->{PID}" if _debugging; $rv = kill $signal, $_->{PID} or _debugging && _debug "$! sending $signal to $_->{PID}" ; } return $rv; }

    and then use that within your pump loop with a parameter of 0;

    pump $h while $h->signal( 0 ) and $out !~ /BRU Server >/i;

    That ought to terminate the loop if the process could not be signalled (has died).

    Obviously untested, but if it works, you could suggest the modification to the maintainer.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.