|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75873 pcntl_wexitstatus returns incorrect on Big_Endian platform (s390x)
Submitted: 2018-01-25 15:34 UTC Modified: 2018-02-23 22:59 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: samding at ca dot ibm dot com Assigned: cmb (profile)
Status: Closed Package: PCNTL related
PHP Version: 7.2.1 OS: RHEL7.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: samding at ca dot ibm dot com
New email:
PHP Version: OS:


 [2018-01-25 15:34 UTC] samding at ca dot ibm dot com
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"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-25 15:51 UTC] 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;
    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.(
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:

 [2018-02-23 22:59 UTC]
Automatic comment on behalf of
Log: Fix #75873: pcntl_wexitstatus returns incorrect on Big_Endian platform (s390x)
 [2018-02-23 22:59 UTC]
-Status: Open +Status: Closed
 [2018-02-23 22:59 UTC]
-Assigned To: +Assigned To: cmb
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 07:01:31 2024 UTC