Bug #75873 [Com]: pcntl_wexitstatus returns incorrect on Big_Endian platform (s390x)
| From: | samding at ca dot ibm dot com | Date: | Thu, 25 Jan 2018 15:52:01 +0000 |
| Subject: | Bug #75873 [Com]: pcntl_wexitstatus returns incorrect on Big_Endian platform (s390x) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213707@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75873&edit=1
ID: 75873
Comment by: samding at ca dot ibm dot com
Reported by: samding at ca dot ibm dot com
Summary: pcntl_wexitstatus returns incorrect on Big_Endian
platform (s390x)
Status: Open
Type: Bug
Package: PCNTL related
Operating System: RHEL7.2
PHP Version: 7.2.1
Block user comment: N
Private report: N
New Comment:
See the code of "pcntl_wexitstatus" of ext/pcntl/pcntl.c
841 PHP_FUNCTION(pcntl_wexitstatus)
842 {
843 #ifdef WEXITSTATUS
844 zend_long status_word;
845
846 if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &status_word) ==
FAILURE) {
847 return;
848 }
849 RETURN_LONG(WEXITSTATUS(status_word));
850 #else
851 RETURN_FALSE;
852 #endif
Here status_word is long, but WEXITSTATUS needs the input as
int.(https://www.gnu.org/software/libc/manual/html_node/Process-Completion-Status.html)
This is no problem on Little_Endian, but causes the problem on Big_Endian platform (s390x).
Have to cast it to int before running macro WEXITSTATUS:
849 RETURN_LONG(WEXITSTATUS((int)status_word));
Similarly following function need to change:
pcntl_wifexited
pcntl_wifstopped
pcntl_wifsignaled
pcntl_wifcontinued
pcntl_wexitstatus
pcntl_wtermsig
pcntl_wstopsig
Previous Comments:
------------------------------------------------------------------------
[2018-01-25 15:34:50] samding at ca dot ibm dot com
Description:
------------
Test case "ext/pcntl/tests/001.phpt" show it result on big_endian platform:
"
Staring wait.h tests....
Testing pcntl_wifexited and wexitstatus....
Exited With: 0
Testing pcntl_wifsignaled....
Testing pcntl_wifstopped and pcntl_wstopsig....
"
Test script:
---------------
sapi/cli/php ext/pcntl/tests/001.php
Expected result:
----------------
"pcntl_wifexited" should return "255"
Actual result:
--------------
"pcntl_wifexited" should return "0"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75873&edit=1