1WaitStat(3)           User Contributed Perl Documentation          WaitStat(3)
2
3
4

NAME

6       Proc::WaitStat - Interpret and act on wait() status values
7

SYNOPSIS

9           $description = waitstat $?;
10           exit waitstat_reuse $?;
11           waitstat_die $?, 'program-name';
12           close_die COMMAND, 'program-name';
13

DESCRIPTION

15       This module contains functions for interpreting and acting on wait
16       status values.
17
18       Nothing is exported by default.
19
20       waitstat wait-status
21           Returns a string representation of wait() status value wait-status.
22           Values returned are like "0" and "64" and "killed (SIGHUP)".
23
24           This function is prototyped to take a single scalar argument.
25
26       waitstat_reuse wait-status
27           Turn wait-status into a value which can be passed to exit,
28           converted in the same manner the shell uses.  If wait-status
29           indicates a normal exit, return the exit value.  If wait-status
30           instead indicates death by signal, return 128 plus the signal
31           number.
32
33           This function is prototyped to take a single scalar argument.
34
35       waitstat_die wait-status program-name
36           die() if wait-status is non-zero (mentioning program-name as the
37           source of the error).
38
39           This function is prototyped to take two scalar arguments.
40
41       close_die filehandle name
42           Close filehandle, if that fails die() with an appropriate message
43           which refers to name.  This handles failed closings of both
44           programs and files properly.
45
46           This function is prototyped to take a filehandle (actually, a glob
47           ref) and a scalar.
48

EXAMPLES

50           close SENDMAIL;
51           exit if $? == 0;
52           log "sendmail failure: ", waitstat $?;
53           exit EX_TEMPFAIL;
54
55           $pid == waitpid $pid, 0 or croak "Failed to reap $pid: $!";
56           exit waitstat_reuse $?;
57
58           $output = `some-program -with args`;
59           waitstat_die $?, 'some-program';
60           print "Output from some-process:\n", $output;
61
62           open PROGRAM, '| post-processor' or die "Can't fork: $!";
63           while (<IN>) {
64               print PROGRAM pre_process $_
65                   or die "Error writing to post-processor: $!";
66           }
67           # This handles both flush failures at close time and a non-zero exit
68           # from the subprocess.
69           close_die PROGRAM, 'post-processor';
70

AUTHOR

72       Roderick Schertler <roderick@argon.org>
73

SEE ALSO

75       perl(1), IPC::Signal(3pm).
76
77
78
79perl v5.32.0                      2020-07-28                       WaitStat(3)
Impressum