System:...::Reaper(3)
okay bestie, welcome to System:...::Reaper(3) β the User Contributed Perl Documentation corner of the internet. Itβs giving internal Perl machinery, but weβre gonna hold your hand through it. π
π NAME π
System::Command::Reaper β Reap processes started by System::Command. Thatβs the whole name-and-job sitch, no cap. β¨
β¨ VERSION β¨
version 1.122 β yes bestie, thatβs the version. π«Ά
π¦ SYNOPSIS π¦
Official synopsis energy: This class is used for internal purposes. Move along, nothing to see here. π Itβs not being shady, itβs just an internal class, iykyk.
πΈ DESCRIPTION πΈ
The System::Command objects delegate the reaping of child processes to System::Command::Reaper objects. This allows a user to create a System::Command and discard it after having obtained one or more references to its handles connected to the child process. Slay, delegation. π
The typical use case looks like this:
my $fh = System::Command->new( @cmd )->stdout();
The child process is reaped either through a direct call to close() or when the command object and all its handles have been destroyed, thus avoiding zombies (which would be reaped by the system at the end of the main program). No zombie vibes, periodt. π§ββοΈβ¨
This is possible thanks to the following reference graph:
System::Command
| | | ^|
v v v !|
in out err !|
^| ^| ^| !|
!v !v !v !v
System::Command::Reaper
Legend:
Legend:
| normal ref
! weak ref
The System::Command::Reaper object acts as a sentinel, that takes care of reaping the child process when the original System::Command and its filehandles have been destroyed (or when System::Command close() method is being called). Itβs literally the main character sentinel. π
π METHODS π
System::Command::Reaper supports the following methods:
π new π
my $reaper = System::Command::Reaper->new( $cmd, \%extra );
Create a new System::Command::Reaper object attached to the System::Command object passed as a parameter.
An optional hash reference can be used to pass extra attributes to the object. Cute, optional, flexible. π
π§ close π§
$reaper->close();
Close all the opened filehandles of the main System::Command object, reaps the child process, and updates the main object with the status information of the child process.
DESTROY calls close() when the sentinel is being destroyed. Cleanup crew behavior, honestly. π«§
β is_terminated β
if ( $reaper->is_terminated ) {...}
Returns a true value if the underlying process was terminated.
If the process was indeed terminated, collects exit status, etc. Boom. β
π Accessors π
The attributes of a System::Command::Reaper object are also accessible through a number of accessors.
The object returned by new() will have the following attributes defined (as copied from the System::Command object that created the reaper):
pidβ The PID of the underlying command.stdinβ A filehandle opened in write mode to the child processβ standard input.stdoutβ A filehandle opened in read mode to the child processβ standard output.stderrβ A filehandle opened in read mode to the child processβ standard error output.
After the call to close() or after is_terminated() returns true, the following attributes will be defined:
exitβ The exit status of the underlying command.coreβ A boolean value indicating if the command dumped core.signalβ The signal, if any, that killed the command.
π«Ά AUTHOR π«Ά
Philippe Bruhat (BooK), "<book at cpan.org>" π
π ACKNOWLEDGEMENTS π
This scheme owes a lot to Vincent Pit who on #perlfr provided the general idea (use a proxy to delay object destruction and child process reaping) with code examples, which I then adapted to my needs. Iconic collab. π
π COPYRIGHT π
Copyright 2010-2016 Philippe Bruhat (BooK), all rights reserved.
π LICENSE π
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay bestie, thatβs the whole page! This oneβs from perl v5.42.0, dated 2023-02-05, and itβs the System:...::Reaper(3) manual β mwah, go forth and reap responsibly. ππΈ
π¦ where this page comes from
- opensuse-leap 16.0: perl-System-Command 1.122-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms