From fb6937270709d9bccab808ea3d3f8eb6be338aa4 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Tue, 26 May 2009 14:02:34 +0000 Subject: [PATCH] MFH: Fix return value of pcntl_wexitstatus() (fixes #47566, patch by james at jamesreno dot com) --- NEWS | 2 ++ ext/pcntl/pcntl.c | 4 +--- ext/pcntl/tests/001.phpt | 2 +- ext/pcntl/tests/bug47566.phpt | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 ext/pcntl/tests/bug47566.phpt diff --git a/NEWS b/NEWS index 89379fbe15..1e46485507 100644 --- a/NEWS +++ b/NEWS @@ -85,6 +85,8 @@ PHP NEWS literal). (Ilia) - Fixed bug #47616 (curl keeps crashing). (Felipe) - Fixed bug #47598 (FILTER_VALIDATE_EMAIL is locale aware). (Ilia) +- Fixed bug #47566 (pcntl_wexitstatus() returns signed status). + (patch by james at jamesreno dot com) - Fixed bug #47564 (unpacking unsigned long 32bit bit endian returns wrong result). (Ilia) - Fixed bug #47487 (performance degraded when reading large chunks after fix of diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index fbc8b8b84a..46a3a96d4f 100755 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -374,9 +374,7 @@ PHP_FUNCTION(pcntl_wexitstatus) status_word = (int) Z_LVAL_PP(status); - /* WEXITSTATUS only returns 8 bits so we *MUST* cast this to signed char - if you want to have valid negative exit codes */ - RETURN_LONG((signed char) WEXITSTATUS(status_word)); + RETURN_LONG(WEXITSTATUS(status_word)); #else RETURN_FALSE; #endif diff --git a/ext/pcntl/tests/001.phpt b/ext/pcntl/tests/001.phpt index 74c529124b..9543d57eb5 100644 --- a/ext/pcntl/tests/001.phpt +++ b/ext/pcntl/tests/001.phpt @@ -73,7 +73,7 @@ test_stop_signal(); Staring wait.h tests.... Testing pcntl_wifexited and wexitstatus.... -Exited With: -1 +Exited With: 255 Testing pcntl_wifsignaled.... Process was terminated by signal : SIGTERM diff --git a/ext/pcntl/tests/bug47566.phpt b/ext/pcntl/tests/bug47566.phpt new file mode 100644 index 0000000000..8a69e6bc73 --- /dev/null +++ b/ext/pcntl/tests/bug47566.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #47566 (return value of pcntl_wexitstatus()) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(128) -- 2.50.1