GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
IO::Async::PID(3) User Contributed Perl Documentation IO::Async::PID(3)

"IO::Async::PID" - event callback on exit of a child process

   use IO::Async::PID;
   use POSIX qw( WEXITSTATUS );

   use IO::Async::Loop;
   my $loop = IO::Async::Loop->new;

   my $kid = $loop->fork(
      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->run;

This subclass of IO::Async::Notifier invokes its callback when a process exits.

For most use cases, a IO::Async::Process object provides more control of setting up the process, connecting filehandles to it, sending data to and receiving data from it.

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":

The process ID to watch. Must be given before the object has been added to the containing IO::Async::Loop object.

CODE reference for the "on_exit" event.

Once the "on_exit" continuation has been invoked, the "IO::Async::PID" object is removed from the containing IO::Async::Loop object.

   $process_id = $pid->pid

Returns the underlying process ID

   $pid->kill( $signal )

Sends a signal to the process

Paul Evans <leonerd@leonerd.org.uk>
2022-04-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.