diff options
author | Bo Lindbergh <blgl@stacken.kth.se> | 2011-05-12 21:42:03 -0700 |
---|---|---|
committer | Jesse Vincent <jesse@bestpractical.com> | 2011-06-07 23:25:07 -0400 |
commit | 0673045fe88b0e4b3f72b8afc1ad54943a7db352 (patch) | |
tree | ca0862b185462d95c2d7ab4aba3d511c0e910910 | |
parent | 2cf968008690b3bb8dca1960425e939f9720233a (diff) | |
download | perl-0673045fe88b0e4b3f72b8afc1ad54943a7db352.tar.gz |
waitpid doesn't work with WIFSTOPPED
> Quoth Emmanuel Rodriguez:
>> I'm see a strange behavior in the fonction WIFSTOPPED($?) when
>> waitpid($pid, WUNTRACED) is invoked and that the child process
>> receives a stop signal. Under this conditions one would expect that
>> WIFSTOPPED($?) would return a true value, but that's not what is
>> happening. A similar program written in C will have the same macro
>> return true instead of false under the same conditions.
>>
>> I can reproduce this with the default perl provided by Ubuntu 9.10 and
>> OS X 10.6. Which lets me guess that this is not a distro related bug.
>
> This is a documentation error. POSIX.pod incorrectly claims that
> you can pass the value of $? to WIFEXITED and its relatives.
> You must use the raw status value from ${^CHILD_ERROR_NATIVE} instead.
And here's the patch. Note that perlvar.pod gets it right already.
/Bo Lindbergh
-rw-r--r-- | ext/POSIX/lib/POSIX.pod | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/ext/POSIX/lib/POSIX.pod b/ext/POSIX/lib/POSIX.pod index 9df0cde498..f7bd0f3a3c 100644 --- a/ext/POSIX/lib/POSIX.pod +++ b/ext/POSIX/lib/POSIX.pod @@ -2188,33 +2188,37 @@ WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG =item WIFEXITED -WIFEXITED($?) returns true if the child process exited normally -(C<exit()> or by falling off the end of C<main()>) +WIFEXITED(${^CHILD_ERROR_NATIVE}) returns true if the child process +exited normally (C<exit()> or by falling off the end of C<main()>) =item WEXITSTATUS -WEXITSTATUS($?) returns the normal exit status of the child process -(only meaningful if WIFEXITED($?) is true) +WEXITSTATUS(${^CHILD_ERROR_NATIVE}) returns the normal exit status of +the child process (only meaningful if WIFEXITED(${^CHILD_ERROR_NATIVE}) +is true) =item WIFSIGNALED -WIFSIGNALED($?) returns true if the child process terminated because -of a signal +WIFSIGNALED(${^CHILD_ERROR_NATIVE}) returns true if the child process +terminated because of a signal =item WTERMSIG -WTERMSIG($?) returns the signal the child process terminated for -(only meaningful if WIFSIGNALED($?) is true) +WTERMSIG(${^CHILD_ERROR_NATIVE}) returns the signal the child process +terminated for (only meaningful if WIFSIGNALED(${^CHILD_ERROR_NATIVE}) +is true) =item WIFSTOPPED -WIFSTOPPED($?) returns true if the child process is currently stopped -(can happen only if you specified the WUNTRACED flag to waitpid()) +WIFSTOPPED(${^CHILD_ERROR_NATIVE}) returns true if the child process is +currently stopped (can happen only if you specified the WUNTRACED flag +to waitpid()) =item WSTOPSIG -WSTOPSIG($?) returns the signal the child process was stopped for -(only meaningful if WIFSTOPPED($?) is true) +WSTOPSIG(${^CHILD_ERROR_NATIVE}) returns the signal the child process +was stopped for (only meaningful if WIFSTOPPED(${^CHILD_ERROR_NATIVE}) +is true) =back |