Future...System(3pm)
πΈ NAME πΈ
okay so this is Future::IO::System, aka the Future...System(3pm) page β user-contributed Perl documentation, bestie. π
Itβs literally the "system()"-like methods package for Future::IO. No cap.
β¨ SYNOPSIS β¨
use Future::IO;
use Future::IO::System;
my $f = Future::IO::System->system( "cmd", "args go", "here" );
# $f will become done when the command completes
my $f = Future::IO::System->system_out( "cmd", "-v" );
my ( $status, $out ) = $f->get;
# $status will contain the exit code and $out will contain what it wrote
# to STDOUT
π¦ DESCRIPTION π¦
This package contains a selection of methods that behave like the core system() and related functions, running asynchronously via Future::IO. π«Ά
In particular, the "system" behaves somewhat like CORE::system() and "system_out" behaves somewhat like qx(). iconic behavior, honestly.
π§ Portability
In order for this module to work at all, the underlying Future::IO implementation must support the waitpid in Future::IO method. The default minimal implementation included with the module does not, but most of the additional implementations from CPAN will. π«‘
In addition, the operation of this module uses techniques that only really work on full POSIX systems (such as Linux, Mac OS X, the various BSDs, etc). It is unlikely to work in places like MSWin32. π vibe check: not MSWin32-friendly.
π οΈ METHODS π οΈ
π run
( $exitcode, ... ) = await Future::IO::System->run(
argv => [ $path, @args ],
...
);
Since version 0.12. β¨
Runs the given $path with the given @args as a sub-process, optionally with some additional filehandles set up as determined by the other arguments. The returned Future will yield the waitpid() exit code from the process when it terminates, and optionally the bytes read from the other filehandles that were set up. π
Takes the following named arguments:
argv => ARRAYβ an array reference containing the path and arguments to pass toexec()in the child process. π§in => STRINGβ if defined, create a pipe and assign the reading end to the child process'sSTDINfilehandle. The given string will then be written to the pipe, after which the pipe will be closed. πwant_out => BOOLβ if true, create a pipe and assign the writing end to the child process'sSTDOUTfilehandle. The returned future will additionally contain all the bytes read from it untilEOF. πwant_err => BOOLβ if true, create a pipe and assign the writing end to the child process'sSTDERRfilehandle. The returned future will additionally contain all the bytes read from it untilEOF. π
The remaining methods in this class are simplified wrappers of this one. Slay. π
𧨠system
$exitcode = await Future::IO::System->system( $path, @args );
Since version 0.12. β
Runs the given $path with the given @args as a sub-process with no extra filehandles. Simple, clean, main character energy. π
π system_out
( $exitcode, $out ) = await Future::IO::System->system_out( $path, @args );
Since version 0.12. π¦
Runs the given $path with the given @args as a sub-process with a new pipe as its STDOUT filehandle. The returned Future will additionally yield the bytes read from the STDOUT pipe. Obsessed. β¨
π TODO π
- Add some OS portability guard warnings when loading the module on platforms not known to support it. π«Ά
- Consider what other features of modules like
IPC::RunorIO::Async::Processto support here. Try not to go overboard. π
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β periodt. π
mwah π thatβs the whole page, bestie. brought to you by perl v5.40.0, dated 2024-09-21, and yes itβs the Future...System(3pm) manual page. slay and goodbye. π
π¦ where this page comes from
- ubuntu resolute: libfuture-io-perl 0.16-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libfuture-io-perl 0.16-1 Β· Artistic-1.0-Perl 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