Proc::Fork

Proc::Fork is a simple, intuitive interface to the fork() system call.
Download

Proc::Fork Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Aristotle Pagaltzis
  • Publisher web site:
  • http://search.cpan.org/~aristotle/Sub-ArgShortcut-1.01/lib/Sub/ArgShortcut.pm

Proc::Fork Tags


Proc::Fork Description

Proc::Fork is a simple, intuitive interface to the fork() system call. Proc::Fork is a simple, intuitive interface to the fork() system call.SYNOPSIS use Proc::Fork; child { # child code goes here. } parent { my $child_pid = shift; # parent code goes here. waitpid $child_pid, 0; } retry { my $attempts = shift; # what to do if if fork() fails: # return true to try again, false to abort return if $attempts > 5; sleep 1, return 1; } error { # Error-handling code goes here # (fork() failed and the retry block returned false) }; # Note the semicolon at the end! Necessary in most casesThis module provides an intuitive, Perl-ish way to write forking programs by letting you use blocks to illustrate which code section executes in which fork. The code for the parent, child, retry handler and error handler are grouped together in a "fork block". The clauses may appear in any order, but they must be consecutive (without any other statements in between).The semicolon after the last clause is mandatory, unless the last clause is at the end of the enclosing block or file.All four clauses need not be specified. If the retry clause is omitted, only one fork will be attempted. If the error clause is omitted the program will die with a simple message if it can't retry. If the parent or child clause is omitted, the respective (parent or child) process will start execution after the final clause. So if one or the other only has to do some simple action, you need only specify that one. For example: # spawn off a child process to do some simple processing child { exec '/bin/ls', '-l'; die "Couldn't exec ls: $!n"; }; # Parent will continue execution from here # ...If the code in any of the clauses does not die or exit, it will continue execution after the fork block. Requirements: · Perl


Proc::Fork Related Software