UV::Process - Process handles in libuv
#!/usr/bin/env perl use strict; use warnings; use UV; my $process = UV::Process->spawn(...)
This module provides an interface to libuv's process handle.
$process->on("exit", sub { my ($invocant, $exit_status, $term_signal) = @_; say "The process exited with status $exit_status" unless $term_signal; say "The process terminated with signal $term_signal" if $term_signal; });
When the process terminates (either by exit or a signal), this event will be fired.
exit
UV::Signal inherits all methods from UV::Handle and also makes the following extra methods available.
my $process = UV::Process->spawn(file => $file, args => \@args);
This constructor method creates a new UV::Process object with the given configuration, and spawns the actual process to begin running. If no UV::Loop is provided then the "default loop" in UV::Loop is assumed.
The following named options are supported:
file: a string giving the command name or path to it.
file
args: a reference to an array of addtional argument values to invoke the command with.
args
env: an optional reference to a hash containing the environment variables for the new process.
env
stdin, stdout, stderr: optional argument to set up a file descriptor in the child process.
stdin
stdout
stderr
Pass a plain integer, or filehandle reference to inherit that FD from the parent.
setuid, setgid: optional integer arguments to attempt to change the user and group ID of the newly-spawned process.
setuid
setgid
Not supported on Windows.
$process->kill($signal);
Sends the specified signal to the process.
my $pid = $process->pid;
Returns the PID number.
Paul Evans <leonerd@leonerd.org.uk>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install UV, copy and paste the appropriate command in to your terminal.
cpanm
cpanm UV
CPAN shell
perl -MCPAN -e shell install UV
For more information on module installation, please visit the detailed CPAN module installation guide.