NAME

Process -- launch and control background processes

SYNOPSIS

use Process;

$myproc = Process->new();             # Create a new process object

$myproc->start("shell-command-line"); # Launch a shell process
$myproc->start(sub { ... });          # Launch a perl subroutine
$myproc->start(\&subroutine);         # Launch a perl subroutine

$running = $myproc->poll();           # Poll Running Process

$myproc->kill();                      # Kill Process (SIGTERM)


$myproc->kill("SIGUSR1");             # Send specified signal

DESCRIPTION

The Process package provides objects that model real-life processes from a user's point of view. A new process object is created by

$myproc = Process->new();

Either shell-like command lines or references to perl subroutines can be specified for launching a process in background. A 10-second sleep process, for example, can be started via the shell as

$myproc->start("sleep 10");

or, as a perl subroutine,

$myproc->start(sub { sleep(10); });

The start Method returns immediately after starting the specified process in background, i.e. non-blocking mode. The start method returns 1 if the process has been launched sucessfully, 0 if not.

The poll method checks if the process is still running

$running = $myproc->poll();

and returns 1 if it is, 0 if it's not. Finally,

$myproc->kill();

terminates the process by sending it the SIGTERM signal. As an option, another signal can be specified.

$myproc->kill("SIGUSR1");

sends the SIGUSR1 to the running process. kill returns 1 if it succeeds in sending the signal, 0 if it doesn't.

AUTHOR

Michael Schilli <schilli@tep.e-technik.tu-muenchen.de>