From 8620c10b3e000d39936fe9aac72fdf06f62e312c Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Tue, 26 May 2009 14:00:42 +0000 Subject: [PATCH] Fix return value of pcntl_wextistatus() (fixes #47566, patch by james at jamesreno dot com) --- ext/pcntl/pcntl.c | 4 +--- ext/pcntl/tests/001.phpt | 2 +- ext/pcntl/tests/bug47566.phpt | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 ext/pcntl/tests/bug47566.phpt diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 58d05502fc7..d85ee2863ea 100755 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -607,9 +607,7 @@ PHP_FUNCTION(pcntl_wexitstatus) return; } - /* 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 d83cae44686..fb1006e4bd1 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 00000000000..8a69e6bc738 --- /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)