@node Proc/Simple, Religion, Proc/Forkfunc, Module List
@unnumbered launch and control background processes


@unnumberedsec NAME

Proc::Simple -- launch and control background processes

@unnumberedsec SYNOPSIS

@example
use Proc::Simple;
@end example

@example
$myproc = Proc::Simple->new();        # Create a new process object
@end example

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

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

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

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

@example
Proc::Simple->debug($level);          # Turn debug on
@end example

@unnumberedsec DESCRIPTION

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

@example
$myproc = Proc::Simple->new();
@end example

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

@example
$myproc->start("sleep 10");
@end example

or, as a perl subroutine, with

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

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

The @emph{poll} method checks if the process is still running

@example
$running = $myproc->poll();
@end example

and returns 1 if it is, @emph{0} if it@'s not. Finally, 

@example
$myproc->kill();
@end example

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

@example
$myproc->kill("SIGUSR1");
@end example

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

@unnumberedsec NOTE

Please keep in mind that there is no guarantee that the SIGTERM
signal really terminates a process. Processes can have signal
handlers defined that avoid the shutdown.
If in doubt, whether a process still exists, check it
repeatedly with the @emph{poll} routine after sending the signal.

@unnumberedsec AUTHOR

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

