IO::Async::PID - event callback on exit of a child process
IO::Async::PID
use IO::Async::PID; use POSIX qw( WEXITSTATUS ); use IO::Async::Loop; my $loop = IO::Async::Loop->new(); my $kid = $loop->detach_child( code => sub { print "Child sleeping..\n"; sleep 10; print "Child exiting\n"; return 20; }, ); print "Child process $kid started\n"; my $pid = IO::Async::PID->new( pid => $kid, on_exit => sub { my ( $self, $exitcode ) = @_; printf "Child process %d exited with status %d\n", $self->pid, WEXITSTATUS($exitcode); }, ); $loop->add( $pid ); $loop->loop_forever;
This subclass of IO::Async::Notifier invokes its callback when a process exits.
The following events are invoked, either using subclass methods or CODE references in parameters:
Invoked when the watched process exits.
The following named parameters may be passed to new or configure:
new
configure
The process ID to watch. Can only be given at construction time.
CODE reference for the on_exit event.
on_exit
Once the on_exit continuation has been invoked, the IO::Async::PID object is removed from the containing IO::Async::Loop object.
IO::Async::Loop
Returns the underlying process ID
Sends a signal to the process
Paul Evans <leonerd@leonerd.org.uk>
To install IO::Async, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Async
CPAN shell
perl -MCPAN -e shell install IO::Async
For more information on module installation, please visit the detailed CPAN module installation guide.