summaryrefslogtreecommitdiff
path: root/pod/perlfunc.pod
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2003-09-16 22:56:20 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2003-09-16 19:48:08 +0000
commit4ef107a6cabd33854b770659cca90f12a2326104 (patch)
tree0182b10ce38f40a2f85afaa02edad4da7bbdfc1c /pod/perlfunc.pod
parent5688dfbf25135c46a375b4553bc0b44f52b55b52 (diff)
downloadperl-4ef107a6cabd33854b770659cca90f12a2326104.tar.gz
[DOC PATCH] Re: [perl #23779] $? and negative exit codes
Message-ID: <20030916205620.GB1246@fdgroup.com> p4raw-id: //depot/perl@21253
Diffstat (limited to 'pod/perlfunc.pod')
-rw-r--r--pod/perlfunc.pod14
1 files changed, 11 insertions, 3 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index d7a3fa46ea..fff672b0f1 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -5745,9 +5745,17 @@ your program.
You can check all the failure possibilities by inspecting
C<$?> like this:
- $exit_value = $? >> 8;
- $signal_num = $? & 127;
- $dumped_core = $? & 128;
+ if ($? == -1) {
+ print "failed to execute: $!\n";
+ }
+ elsif ($? & 127) {
+ printf "child died with signal %d, %s coredump\n",
+ ($? & 127), ($? & 128) ? 'with' : 'without';
+ }
+ else {
+ printf "child exited with value %d\n", $? >> 8;
+ }
+
or more portably by using the W*() calls of the POSIX extension;
see L<perlport> for more information.