The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Reflex::PID - Observe the exit of a subprocess by its SIGCHLD signal.

VERSION

version 0.085

SYNOPSIS

# Not a complete program. Please see the source for # Reflex::POE::Wheel::Run for one example.

        use Reflex::PID;

        observes pid_watcher => (
                isa   => 'Reflex::PID|Undef',
                role  => 'process',
        );

        sub some_method {
                my $self = shift;

                my $pid = fork();
                die $! unless defined $pid;
                exec("some-program.pl") unless $pid;

                # Parent here.
                $self->sigchild_watcher(
                        Reflex::PID->new(pid => $pid)
                );
        }

        sub on_process_exit {
                # Handle the event.
        }

DESCRIPTION

Reflex::PID waits for a particular child process to exit. It emits a "signal" event with information about the child process when it has detected the child has exited.

Since Reflex::PID waits for a particular process ID, it's pretty much useless afterwards. Consider pairing it with Reflex::Collection if you have to maintain several transient processes.

Reflex::PID extends Reflex::Signal to handle a particular kind of signal---SIGCHLD.

TODO - However, first we need to make Reflex::PID objects stop themselves and emit "stopped" events when they're done. Otherwise Reflex::Collection won't know when to destroy them.

Public Events

exit

Reflex::PID's "exit" event includes two named parameters. "pid" contains the process ID that exited. "exit" contains the process' exit value---a copy of $? at the time the process exited. Please see "$?" in perlvar for more information about that special Perl variable.

SEE ALSO

Moose::Manual::Concepts

Reflex Reflex::Signal Reflex::POE::Wheel::Run

"ACKNOWLEDGEMENTS" in Reflex "ASSISTANCE" in Reflex "AUTHORS" in Reflex "BUGS" in Reflex "BUGS" in Reflex "CONTRIBUTORS" in Reflex "COPYRIGHT" in Reflex "LICENSE" in Reflex "TODO" in Reflex