]> granicus.if.org Git - php/commitdiff
MFH: Fix return value of pcntl_wexitstatus() (fixes #47566,
authorArnaud Le Blanc <lbarnaud@php.net>
Tue, 26 May 2009 14:02:34 +0000 (14:02 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Tue, 26 May 2009 14:02:34 +0000 (14:02 +0000)
patch by james at jamesreno dot com)

NEWS
ext/pcntl/pcntl.c
ext/pcntl/tests/001.phpt
ext/pcntl/tests/bug47566.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 89379fbe15c5797f5f8a055252337f6599650bbf..1e4648550712c978ed9f871dc24d20a1fb59ed64 100644 (file)
--- 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
index fbc8b8b84a8bb80ce9b461a9a13c2af487161225..46a3a96d4f37cc23861414912f030cd73aec12e4 100755 (executable)
@@ -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
index 74c529124bf712ea675b90e0ef0c00201e41ef0c..9543d57eb5e6a20aa0fc4417a099e617d01f3152 100644 (file)
@@ -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 (file)
index 0000000..8a69e6b
--- /dev/null
@@ -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)