-
-
30 Jun 2019 08:19:09 UTC
- Distribution: IO-Lambda
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (0)
- Testers (563 / 103 / 0)
- Kwalitee
Bus factor: 1- % Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (90.24KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- LWP
- Net::DNS
- Scalar::Util
- Storable
- Sub::Name
- Time::HiRes
- URI
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
IO::Lambda::Signal - wait for pids and signals
DESCRIPTION
The module provides access to the signal-based callbacks: generic signal listener
signal
, process ID listenerpid
, and the asynchronous version of system call,spawn
.SYNOPSIS
use strict; use IO::Lambda qw(:all); use IO::Lambda::Signal qw(pid spawn); # pid my $pid = fork; exec "/bin/ls" unless $pid; lambda { context $pid, 5; pid { my $ret = shift; print defined($ret) ? ("exitcode(", $ret>>8, ")\n") : "timeout\n"; } }-> wait; # spawn this lambda { context "perl -v"; spawn { my ( $buf, $exitcode, $error) = @_; print "buf=[$buf], exitcode=$exitcode, error=$error\n"; } }-> wait;
USAGE
- pid ($PID, $TIMEOUT) -> $?|undef
-
Accepts PID and an optional deadline/timeout, returns either the process' exit status, or undef on timeout. The corresponding lambda is
new_pid
:new_pid ($PID, $TIMEOUT) :: () -> $?|undef
- signal ($SIG, $TIMEOUT) -> boolean
-
Accepts signal name and optional deadline/timeout, returns 1 if the signal was caught, or
undef
on timeout. The corresponding lambda isnew_signal
:new_signal ($SIG, $TIMEOUT) :: () -> boolean
- spawn (@LIST) -> ( output, $?, $!)
-
Calls pipe open on
@LIST
, reads all data printed by the child process, and awaits for the process to finish. Returns three scalars - collected output, process exitcode$?
, and an error string (usually$!
). The corresponding lambda isnew_process
:new_process (@LIST) :: () -> ( output, $?, $!)
Lambda objects created by
new_process
have an additional field'pid'
initialized with the process pid value.
LIMITATION
pid
andnew_pid
don't work on win32 because win32 doesn't use SIGCHLD/waitpid. Native implementation ofspawn
andnew_process
doesn't work for the same reason on win32 as well, therefore those were reimplemented using threads, and require a threaded perl.SEE ALSO
IO::Lambda, perlipc, IPC::Open2, IPC::Run
AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>.
Module Install Instructions
To install IO::Lambda, copy and paste the appropriate command in to your terminal.
cpanm IO::Lambda
perl -MCPAN -e shell install IO::Lambda
For more information on module installation, please visit the detailed CPAN module installation guide.