summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
authorGisle Aas <gisle@aas.no>2005-05-18 01:35:47 -0700
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-05-18 16:08:30 +0000
commite5218da503dbb4980410e0018f4cc5dcba3ea666 (patch)
tree896f8cf586a22fa6f98384571dea2ba73b133df3 /pod
parent6b09c1601036c61459334bdedef5d7e29e07fcaf (diff)
downloadperl-e5218da503dbb4980410e0018f4cc5dcba3ea666.tar.gz
Well defined $? and introduction of ${^CHILD_ERROR_NATIVE} [PATCH]
Message-ID: <lr8y2cim24.fsf_-_@caliper.activestate.com> p4raw-id: //depot/perl@24501
Diffstat (limited to 'pod')
-rw-r--r--pod/perlfunc.pod15
-rw-r--r--pod/perlport.pod10
-rw-r--r--pod/perlvar.pod13
3 files changed, 21 insertions, 17 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index a428b5f655..5414e324d4 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -782,7 +782,8 @@ program exits with non-zero status. (If the only problem was that the
program exited non-zero, C<$!> will be set to C<0>.) Closing a pipe
also waits for the process executing on the pipe to complete, in case you
want to look at the output of the pipe afterwards, and
-implicitly puts the exit status value of that command into C<$?>.
+implicitly puts the exit status value of that command into C<$?> and
+C<${^CHILD_ERROR_NATIVE}>.
Prematurely closing the read end of a pipe (i.e. before the process
writing to it at the other end has closed it) will result in a
@@ -3126,7 +3127,8 @@ be set for the newly opened file descriptor as determined by the value
of $^F. See L<perlvar/$^F>.
Closing any piped filehandle causes the parent process to wait for the
-child to finish, and returns the status value in C<$?>.
+child to finish, and returns the status value in C<$?> and
+C<${^CHILD_ERROR_NATIVE}>.
The filename passed to 2-argument (or 1-argument) form of open() will
have leading and trailing whitespace deleted, and the normal
@@ -5975,8 +5977,8 @@ C<$?> like this:
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.
+Alternatively you might inspect the value of C<${^CHILD_ERROR_NATIVE}>
+with the W*() calls of the POSIX extension.
When the arguments get executed via the system shell, results
and return codes will be subject to its quirks and capabilities.
@@ -6761,7 +6763,8 @@ example should print the following table:
Behaves like the wait(2) system call on your system: it waits for a child
process to terminate and returns the pid of the deceased process, or
-C<-1> if there are no child processes. The status is returned in C<$?>.
+C<-1> if there are no child processes. The status is returned in C<$?>
+and C<{^CHILD_ERROR_NATIVE}.
Note that a return value of C<-1> could mean that child processes are
being automatically reaped, as described in L<perlipc>.
@@ -6770,7 +6773,7 @@ being automatically reaped, as described in L<perlipc>.
Waits for a particular child process to terminate and returns the pid of
the deceased process, or C<-1> if there is no such child process. On some
systems, a value of 0 indicates that there are processes still running.
-The status is returned in C<$?>. If you say
+The status is returned in C<$?> and C<{^CHILD_ERROR_NATIVE}. If you say
use POSIX ":sys_wait_h";
#...
diff --git a/pod/perlport.pod b/pod/perlport.pod
index e250ea183b..36a87050ba 100644
--- a/pod/perlport.pod
+++ b/pod/perlport.pod
@@ -1942,16 +1942,6 @@ OS>, OS/390, VM/ESA)
=item system
-In general, do not assume the UNIX/POSIX semantics that you can shift
-C<$?> right by eight to get the exit value, or that C<$? & 127>
-would give you the number of the signal that terminated the program,
-or that C<$? & 128> would test true if the program was terminated by a
-coredump. Instead, use the POSIX W*() interfaces: for example, use
-WIFEXITED($?) and WEXITVALUE($?) to test for a normal exit and the exit
-value, WIFSIGNALED($?) and WTERMSIG($?) for a signal exit and the
-signal. Core dumping is not a portable concept, so there's no portable
-way to test for that.
-
Only implemented if ToolServer is installed. (S<Mac OS>)
As an optimization, may not call the command shell specified in
diff --git a/pod/perlvar.pod b/pod/perlvar.pod
index 53fe6c92c8..a9bbdaea57 100644
--- a/pod/perlvar.pod
+++ b/pod/perlvar.pod
@@ -617,7 +617,7 @@ L<perlfunc/formline()>.
The status returned by the last pipe close, backtick (C<``>) command,
successful call to wait() or waitpid(), or from the system()
operator. This is just the 16-bit status word returned by the
-wait() system call (or else is made up to look like it). Thus, the
+traditional Unix wait() system call (or else is made up to look like it). Thus, the
exit value of the subprocess is really (C<<< $? >> 8 >>>), and
C<$? & 127> gives which signal, if any, the process died from, and
C<$? & 128> reports whether there was a core dump. (Mnemonic:
@@ -643,6 +643,17 @@ status; see L<perlvms/$?> for details.
Also see L<Error Indicators>.
+=item ${^CHILD_ERROR_NATIVE}
+
+The native status returned by the last pipe close, backtick (C<``>)
+command, successful call to wait() or waitpid(), or from the system()
+operator. On POSIX-like systems this value can be decoded with the
+WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG
+and WIFCONTINUED functions provided by the L<POSIX> module.
+
+Under VMS this reflects the actual VMS exit status; i.e. it is the same
+as $? when the pragma C<use vmsish 'status'> is in effect.
+
=item ${^ENCODING}
The I<object reference> to the Encode object that is used to convert