Test2::Harness::IPC - Base class for modules that control child processes.
This module is the base class for all parts of Test2::Harness that have to do process management.
The root PID of the IPC object.
Custom signal handlers specific to the IPC object.
Hashref of $pid => $proc where $proc is an instance of Test2::Harness::IPC::Proc.
$pid => $proc
Hashref of $category => { $pid => $proc }.
$category => { $pid => $proc }
Hashref of processes that have finished, but have not been handled yet.
This is an implementation detail you should not rely on.
How long to sleep between loops when in a wait cycle.
True if the IPC process has started.
Implementation detail, used to break wait loops when signals are received.
Start the IPC management (Insert signal handlers).
Stop the IPC management (Remove signal handlers).
Set a custom signal handler. This is a safer version of local %SIG{$sig} for use with IPC.
local %SIG{$sig}
The callback will get exactly one argument, the name of the signal that was recieved.
Handle the specified signal. Will cause process exit if the signal has no handler.
Kill all tracked child process with the given signal. TERM is used if no signal is specified.
TERM
This will not wait on the processes, you must call $ipc->wait().
$ipc->wait()
This is a no-op on the IPC base class. This is called every loop of $ipc->wait. If you subclass the IPC class you can fill this in to make processes timeout if needed.
$ipc->wait
This is used a lot internally to check if this is a forked process. If this is a forked process the IPC object is completely reset with no remaining internal state (except signal handlers).
Calls $proc->set_exit(@args). This is called by $ipc->wait. You can override it to add custom tasks when a process exits.
$proc->set_exit(@args)
Wait on processes, return the number found.
Default is non-blocking.
Options:
If a blocking paremeter is provided this can be used to break the wait after a timeout. Time::HiRes is used, so timeout is in seconds with decimals.
Block until ALL processes are done.
Block until at least 1 process from the category is complete.
Block until ALL processes from the category are complete.
Block until at least 1 process is complete.
Add a process to be monitored.
In the first form $proc is an instance of Test2::Harness::IPC::Proc that provides spawn_params().
spawn_params()
In the second form the following params are allowed:
Anything supported by run_cmd() in Test2::Harness::Util::IPC.
run_cmd()
Default is Test2::Harness::IPC::Process.
Program command to call. This is required.
Specify custom environment variables for the new process.
The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.
Copyright 2020 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
To install Test2::Harness, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test2::Harness
CPAN shell
perl -MCPAN -e shell install Test2::Harness
For more information on module installation, please visit the detailed CPAN module installation guide.