NAME

UV::Process - Process handles in libuv

SYNOPSIS

#!/usr/bin/env perl
use strict;
use warnings;

use UV;

my $process = UV::Process->spawn(...)

DESCRIPTION

This module provides an interface to libuv's process handle.

EVENTS

exit

$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.

METHODS

UV::Signal inherits all methods from UV::Handle and also makes the following extra methods available.

spawn (class method)

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.

  • args: a reference to an array of addtional argument values to invoke the command with.

  • env: an optional reference to a hash containing the environment variables for the new process.

  • stdin, stdout, stderr: optional argument to set up a file descriptor in the child process.

    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.

    Not supported on Windows.

kill

$process->kill($signal);

Sends the specified signal to the process.

pid

my $pid = $process->pid;

Returns the PID number.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.