diff options
author | Arnaud Le Blanc <lbarnaud@php.net> | 2009-05-26 14:01:39 +0000 |
---|---|---|
committer | Arnaud Le Blanc <lbarnaud@php.net> | 2009-05-26 14:01:39 +0000 |
commit | f2b8b7f4e05cf5616547037de35d99e5104d169c (patch) | |
tree | 1080d148e214160342108bb1053d806b42e2834c /ext/pcntl | |
parent | 49884703037bf10bc1f3f94901ba9042808aa178 (diff) | |
download | php-git-f2b8b7f4e05cf5616547037de35d99e5104d169c.tar.gz |
MFH: Fix return value of pcntl_wexitstatus() (fixes #47566,
patch by james at jamesreno dot com)
Diffstat (limited to 'ext/pcntl')
-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) |