| 1 | # -*-perl-*- | ||
| 2 | ########################################################################### | ||
| 3 | =pod | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | reaper - support for reaping child processes via $SIG{CHLD} | ||
| 8 | |||
| 9 | =head1 SYNOPSIS | ||
| 10 | |||
| 11 | use reaper qw( reaper reapPid pidStatus ); | ||
| 12 | |||
| 13 | my $pid = fork; | ||
| 14 | if ( $pid == 0 ) { # child | ||
| 15 | exec $some_command; | ||
| 16 | } | ||
| 17 | reapPid ( $pid ); | ||
| 18 | |||
| 19 | ... | ||
| 20 | |||
| 21 | if ( defined(my $exit = pidStatus($pid)) ) { | ||
| 22 | # child exited, check the code... | ||
| 23 | } | ||
| 24 | |||
| 25 | |||
| 26 | =head1 DESCRIPTION | ||
| 27 | |||
| 28 | reaper is just a backwards-compatibility wrapper for Reaper -- turns | ||
| 29 | out that only 'pragmas' are supposed to be named in lower case, so I | ||
| 30 | renamed reaper to Reaper. But existing code contains 'use reaper', so | ||
| 31 | this allows such code to work without changes. | ||
| 32 | |||
| 33 | =cut | ||
| 34 | #' | ||
| 35 | ########################################################################### | ||
| 36 | |||
| 37 | use strict; | ||
| 38 | |||
| 39 | package reaper; | ||
| 40 | use Reaper qw( reaper reapPid pidStatus ); | ||
| 41 | @reaper::EXPORT = qw(); | ||
| 42 | @reaper::EXPORT_OK = qw( reaper reapPid pidStatus ); | ||
| 43 | |||
| 44 | |||
| 45 | ########################################################################### | ||
| 46 | # End of package | ||
| 47 | ########################################################################### | ||
| 48 | package main; | ||
| 49 | 1; | ||
| 50 | __END__ |