Bug #75873 [Opn->Csd]: pcntl_wexitstatus returns incorrect on Big_Endian platform (s390x)
| From: | cmb@php.net | Date: | Fri, 23 Feb 2018 22:59:06 +0000 |
| Subject: | Bug #75873 [Opn->Csd]: pcntl_wexitstatus returns incorrect on Big_Endian platform (s390x) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214095@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
Updated by: cmb@php.net
Reported by: samding at ca dot ibm dot com
Summary: pcntl_wexitstatus returns incorrect on Big_Endian
platform (s390x)
-Status: Open
+Status: Closed
Type: Bug
Package: PCNTL related
Operating System: RHEL7.2
PHP Version: 7.2.1
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of samding@ca.ibm.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=78c1ef2adbd3f9383659326cc85e7f45fef639ae
Log: Fix #75873: pcntl_wexitstatus returns incorrect on Big_Endian platform (s390x)
Previous Comments:
------------------------------------------------------------------------
[2018-01-25 15:51:58] samding at ca dot ibm dot com
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
------------------------------------------------------------------------
[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