NAME
Zoidberg::Contractor - Module to manage jobs
SYNOPSIS
use Zoidberg::Contractor;
my $c = Zoidberg::Contractor->new();
$c->shell_list( [qw(cat ./log)], '|', [qw(grep -i error)] );
DESCRIPTION
Zoidberg inherits from this module, it manages jobs.
It uses Zoidberg::StringParser.
Also it defines Zoidberg::Job and subclasses.
FIXME lots of documentation
METHODS
- new()
-
Simple constructor, calls
shell_init()
. - shell_init()
-
Initialises things like hashes with signal names and sets terminal control. Should be called before usage when the constructor is overloaded.
- round_up()
-
Recursively calls the
round_up()
function of all current jobs. - shell_list(@blocks)
-
Executes a list of jobs and logic operators.
- shell_job($block)
-
Executes a single job.
- reap_jobs()
-
Checks for jobs that are finished and removes them from the job list.
- job_by_id($id)
-
Returns a job object based on the (numeric) id.
(Note that the job list is un-ordered, so the id and the index are not usually identical.)
- job_by_spec($string)
-
Returns a job object based on a string. The following formats are supported:
- sig_by_spec($string)
-
Returns the signal number for a named signal or undef if no such signal exists.
JOBS
Jobs are objects of the class Zoidberg::Job
or a subclass of this class.
This object AUTOLOADS methods to process signals. For example:
$job->TERM(); # is identical to
$job->kill('TERM');
Methods
The job obbjects have the following methods:
- new()
-
Simple constructor.
- exec()
-
Execute the job.
- round_up()
-
Recursively kill the job, ends all child processes forcefully.
- fg()
-
Take terminal control and run this job in the foreground.
- bg()
-
Run this job in the background.
- kill($signal, $wipe_list)
-
Sends $signal (numeric or named) to all child processes belonging to this job; $signal defaults to SIGTERM.
If the boolean $wipe_list is set all jobs pending in the same logic list are removed.
- env(\%env)
-
Set local environment for the current job. Can't be set after the job has started.
- fd(\@redir)
-
Set redirections for the current job. Can't be set after the job has started.
AUTHORS
Jaap Karssenberg, <pardus@cpan.org>
Raoul Zwart, <rlzwart@cpan.org>
Copyright (c) 2011 Jaap G Karssenberg and Joel Berger. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.