1Test2::Harness::IPC(3)User Contributed Perl DocumentationTest2::Harness::IPC(3)
2
3
4

NAME

6       Test2::Harness::IPC - Base class for modules that control child
7       processes.
8

DESCRIPTION

10       This module is the base class for all parts of Test2::Harness that have
11       to do process management.
12

ATTRIBUTES

14       $pid = $ipc->pid
15           The root PID of the IPC object.
16
17       $hashref = $ipc->handlers
18           Custom signal handlers specific to the IPC object.
19
20       $hashref = $ipc->procs
21           Hashref of "$pid => $proc" where $proc is an instance of
22           Test2::Harness::IPC::Proc.
23
24       $hashref = $ipc->procs_by_cat
25           Hashref of "$category => { $pid => $proc }".
26
27       $hashref = $ipc->waiting
28           Hashref of processes that have finished, but have not been handled
29           yet.
30
31           This is an implementation detail you should not rely on.
32
33       $float = $ipc->wait_time
34           How long to sleep between loops when in a wait cycle.
35
36       $bool = $ipc->started
37           True if the IPC process has started.
38
39       $ipc->sig_count
40           Implementation detail, used to break wait loops when signals are
41           received.
42

METHODS

44       $ipc->start
45           Start the IPC management (Insert signal handlers).
46
47       $ipc->stop
48           Stop the IPC management (Remove signal handlers).
49
50       $ipc->set_sig_handler($sig, sub { ... })
51           Set a custom signal handler. This is a safer version of "local
52           %SIG{$sig}" for use with IPC.
53
54           The callback will get exactly one argument, the name of the signal
55           that was recieved.
56
57       $ipc->handle_sig($sig)
58           Handle the specified signal. Will cause process exit if the signal
59           has no handler.
60
61       $ipc->killall()
62       $ipc->killall($sig)
63           Kill all tracked child process with the given signal. "TERM" is
64           used if no signal is specified.
65
66           This will not wait on the processes, you must call "$ipc->wait()".
67
68       $ipc->check_timeouts
69           This is a no-op on the IPC base class. This is called every loop of
70           "$ipc->wait". If you subclass the IPC class you can fill this in to
71           make processes timeout if needed.
72
73       $ipc->check_for_fork
74           This is used a lot internally to check if this is a forked process.
75           If this is a forked process the IPC object is completely reset with
76           no remaining internal state (except signal handlers).
77
78       $ipc->set_proc_exit($proc, @args)
79           Calls "$proc->set_exit(@args)". This is called by "$ipc->wait". You
80           can override it to add custom tasks when a process exits.
81
82       $int = $ipc->wait()
83       $int = $ipc->wait(%params)
84           Wait on processes, return the number found.
85
86           Default is non-blocking.
87
88           Options:
89
90           timeout => $float
91               If a blocking paremeter is provided this can be used to break
92               the wait after a timeout. Time::HiRes is used, so timeout is in
93               seconds with decimals.
94
95           all => $bool
96               Block until ALL processes are done.
97
98           cat => $category
99               Block until at least 1 process from the category is complete.
100
101           all_cat => $category
102               Block until ALL processes from the category are complete.
103
104           block => $bool
105               Block until at least 1 process is complete.
106
107       $ipc->watch($proc)
108           Add a process to be monitored.
109
110       $proc = $ipc->spawn($proc)
111       $proc = $ipc->spawn(%params)
112           In the first form $proc is an instance of Test2::Harness::IPC::Proc
113           that provides "spawn_params()".
114
115           In the second form the following params are allowed:
116
117           Anything supported by "run_cmd()" in Test2::Harness::Util::IPC.
118
119           process_class => $CLASS
120               Default is Test2::Harness::IPC::Process.
121
122           command => $command
123               Program command to call. This is required.
124
125           env_vars => { ... }
126               Specify custom environment variables for the new process.
127

SOURCE

129       The source code repository for Test2-Harness can be found at
130       http://github.com/Test-More/Test2-Harness/.
131

MAINTAINERS

133       Chad Granum <exodist@cpan.org>
134

AUTHORS

136       Chad Granum <exodist@cpan.org>
137
139       Copyright 2020 Chad Granum <exodist7@gmail.com>.
140
141       This program is free software; you can redistribute it and/or modify it
142       under the same terms as Perl itself.
143
144       See http://dev.perl.org/licenses/
145
146
147
148perl v5.32.0                      2020-07-28            Test2::Harness::IPC(3)
Impressum