diff options
Diffstat (limited to 'ext')
-rwxr-xr-x | ext/pcntl/pcntl.c | 4 | ||||
-rw-r--r-- | ext/pcntl/tests/001.phpt | 2 | ||||
-rw-r--r-- | ext/pcntl/tests/bug47566.phpt | 19 |
3 files changed, 21 insertions, 4 deletions
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index e5ce729b37..bee1693f1d 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 d83cae4468..fb1006e4bd 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-- +<?php if (!extension_loaded("pcntl")) print "skip"; ?> +--FILE-- +<? +$pid = pcntl_fork(); +if ($pid == -1) { + echo "Unable to fork"; + exit; +} elseif ($pid) { + $epid = pcntl_waitpid(-1,$status); + var_dump(pcntl_wexitstatus($status)); +} else { + exit(128); +} +?> +--EXPECT-- +int(128) |