1System::Command::ReaperU(s3e)r Contributed Perl DocumentaStyisotnem::Command::Reaper(3)
2
3
4

NAME

6       System::Command::Reaper - Reap processes started by System::Command
7

VERSION

9       version 1.119
10

SYNOPSIS

12       This class is used for internal purposes.  Move along, nothing to see
13       here.
14

DESCRIPTION

16       The System::Command objects delegate the reaping of child processes to
17       System::Command::Reaper objects. This allows a user to create a
18       System::Command and discard it after having obtained one or more
19       references to its handles connected to the child process.
20
21       The typical use case looks like this:
22
23           my $fh = System::Command->new( @cmd )->stdout();
24
25       The child process is reaped either through a direct call to "close()"
26       or when the command object and all its handles have been destroyed,
27       thus avoiding zombies (which would be reaped by the system at the end
28       of the main program).
29
30       This is possible thanks to the following reference graph:
31
32               System::Command
33                |   |   |  ^|
34                v   v   v  !|
35               in out err  !|
36               ^|  ^|  ^|  !|
37               !v  !v  !v  !v
38           System::Command::Reaper
39
40       Legend:
41           | normal ref
42           ! weak ref
43
44       The System::Command::Reaper object acts as a sentinel, that takes care
45       of reaping the child process when the original System::Command and its
46       filehandles have been destroyed (or when System::Command "close()"
47       method is being called).
48

METHODS

50       System::Command::Reaper supports the following methods:
51
52   new
53           my $reaper = System::Command::Reaper->new( $cmd, \%extra );
54
55       Create a new System::Command::Reaper object attached to the
56       System::Command object passed as a parameter.
57
58       An optional hash reference can be used to pass extra attributes to the
59       object.
60
61   close
62           $reaper->close();
63
64       Close all the opened filehandles of the main System::Command object,
65       reaps the child process, and updates the main object with the status
66       information of the child process.
67
68       "DESTROY" calls "close()" when the sentinel is being destroyed.
69
70   is_terminated
71           if ( $reaper->is_terminated ) {...}
72
73       Returns a true value if the underlying process was terminated.
74
75       If the process was indeed terminated, collects exit status, etc.
76
77   Accessors
78       The attributes of a System::Command::Reaper object are also accessible
79       through a number of accessors.
80
81       The object returned by "new()" will have the following attributes
82       defined (as copied from the System::Command object that created the
83       reaper):
84
85       pid The PID of the underlying command.
86
87       stdin
88           A filehandle opened in write mode to the child process' standard
89           input.
90
91       stdout
92           A filehandle opened in read mode to the child process' standard
93           output.
94
95       stderr
96           A filehandle opened in read mode to the child process' standard
97           error output.
98
99       After the call to "close()" or after "is_terminated()" returns true,
100       the following attributes will be defined:
101
102       exit
103           The exit status of the underlying command.
104
105       core
106           A boolean value indicating if the command dumped core.
107
108       signal
109           The signal, if any, that killed the command.
110

AUTHOR

112       Philippe Bruhat (BooK), "<book at cpan.org>"
113

ACKNOWLEDGEMENTS

115       This scheme owes a lot to Vincent Pit who on #perlfr provided the
116       general idea (use a proxy to delay object destruction and child process
117       reaping) with code examples, which I then adapted to my needs.
118
120       Copyright 2010-2016 Philippe Bruhat (BooK), all rights reserved.
121

LICENSE

123       This program is free software; you can redistribute it and/or modify it
124       under the same terms as Perl itself.
125
126
127
128perl v5.30.0                      2019-07-26        System::Command::Reaper(3)
Impressum