summaryrefslogtreecommitdiff
path: root/ext/pcntl
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2009-06-24 22:49:04 +0200
committerSean Finney <seanius@debian.org>2009-06-24 22:49:04 +0200
commit84f4ca9b07fe5b73d840258f4aa7c1eb534c4253 (patch)
tree9829bd578af8a4a8b42b04277f9067e00dc5ad90 /ext/pcntl
parent6821b67124604da690c5e9276d5370d679c63ac8 (diff)
downloadphp-84f4ca9b07fe5b73d840258f4aa7c1eb534c4253.tar.gz
Imported Upstream version 5.3.0~RC4upstream/5.3.0_RC4upstream/5.3.0.RC4
Diffstat (limited to 'ext/pcntl')
-rwxr-xr-xext/pcntl/pcntl.c88
-rw-r--r--ext/pcntl/tests/001.phpt2
-rw-r--r--ext/pcntl/tests/002.phpt3
-rw-r--r--ext/pcntl/tests/003.phpt32
-rw-r--r--ext/pcntl/tests/bug47566.phpt19
-rwxr-xr-xext/pcntl/tests/signal_closure_handler.phpt1
6 files changed, 136 insertions, 9 deletions
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index f385cf555..85f08e24a 100755
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pcntl.c,v 1.48.2.2.2.4.2.15 2008/12/31 11:15:40 sebastian Exp $ */
+/* $Id: pcntl.c,v 1.48.2.2.2.4.2.21 2009/05/26 14:01:39 lbarnaud Exp $ */
#define PCNTL_DEBUG 0
@@ -264,8 +264,8 @@ void php_register_signal_constants(INIT_FUNC_ARGS)
/* {{{ "how" argument for sigprocmask */
#ifdef HAVE_SIGPROCMASK
REGISTER_LONG_CONSTANT("SIG_BLOCK", SIG_BLOCK, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIG_UNBLOCK", SIG_BLOCK, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIG_SETMASK", SIG_BLOCK, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIG_UNBLOCK", SIG_UNBLOCK, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIG_SETMASK", SIG_SETMASK, CONST_CS | CONST_PERSISTENT);
#endif
/* }}} */
@@ -290,50 +290,120 @@ void php_register_signal_constants(INIT_FUNC_ARGS)
#endif
/* si_code for SIGCHILD */
+#ifdef CLD_EXITED
REGISTER_LONG_CONSTANT("CLD_EXITED", CLD_EXITED, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef CLD_KILLED
REGISTER_LONG_CONSTANT("CLD_KILLED", CLD_KILLED, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef CLD_DUMPED
REGISTER_LONG_CONSTANT("CLD_DUMPED", CLD_DUMPED, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef CLD_TRAPPED
REGISTER_LONG_CONSTANT("CLD_TRAPPED", CLD_TRAPPED, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef CLD_STOPPED
REGISTER_LONG_CONSTANT("CLD_STOPPED", CLD_STOPPED, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef CLD_CONTINUED
REGISTER_LONG_CONSTANT("CLD_CONTINUED", CLD_CONTINUED, CONST_CS | CONST_PERSISTENT);
+#endif
/* si_code for SIGTRAP */
+#ifdef TRAP_BRKPT
REGISTER_LONG_CONSTANT("TRAP_BRKPT", TRAP_BRKPT, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef TRAP_TRACE
REGISTER_LONG_CONSTANT("TRAP_TRACE", TRAP_TRACE, CONST_CS | CONST_PERSISTENT);
+#endif
/* si_code for SIGPOLL */
+#ifdef POLL_IN
REGISTER_LONG_CONSTANT("POLL_IN", POLL_IN, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef POLL_OUT
REGISTER_LONG_CONSTANT("POLL_OUT", POLL_OUT, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef POLL_MSG
REGISTER_LONG_CONSTANT("POLL_MSG", POLL_MSG, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef POLL_ERR
REGISTER_LONG_CONSTANT("POLL_ERR", POLL_ERR, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef POLL_PRI
REGISTER_LONG_CONSTANT("POLL_PRI", POLL_PRI, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef POLL_HUP
REGISTER_LONG_CONSTANT("POLL_HUP", POLL_HUP, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef ILL_ILLOPC
REGISTER_LONG_CONSTANT("ILL_ILLOPC", ILL_ILLOPC, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef ILL_ILLOPN
REGISTER_LONG_CONSTANT("ILL_ILLOPN", ILL_ILLOPN, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef ILL_ILLADR
REGISTER_LONG_CONSTANT("ILL_ILLADR", ILL_ILLADR, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef ILL_ILLTRP
REGISTER_LONG_CONSTANT("ILL_ILLTRP", ILL_ILLTRP, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef ILL_PRVOPC
REGISTER_LONG_CONSTANT("ILL_PRVOPC", ILL_PRVOPC, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef ILL_PRVREG
REGISTER_LONG_CONSTANT("ILL_PRVREG", ILL_PRVREG, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef ILL_COPROC
REGISTER_LONG_CONSTANT("ILL_COPROC", ILL_COPROC, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef ILL_BADSTK
REGISTER_LONG_CONSTANT("ILL_BADSTK", ILL_BADSTK, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef FPE_INTDIV
REGISTER_LONG_CONSTANT("FPE_INTDIV", FPE_INTDIV, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef FPE_INTOVF
REGISTER_LONG_CONSTANT("FPE_INTOVF", FPE_INTOVF, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef FPE_FLTDIV
REGISTER_LONG_CONSTANT("FPE_FLTDIV", FPE_FLTDIV, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef FPE_FLTOVF
REGISTER_LONG_CONSTANT("FPE_FLTOVF", FPE_FLTOVF, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef FPE_FLTUND
REGISTER_LONG_CONSTANT("FPE_FLTUND", FPE_FLTINV, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef FPE_FLTRES
REGISTER_LONG_CONSTANT("FPE_FLTRES", FPE_FLTRES, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef FPE_FLTINV
REGISTER_LONG_CONSTANT("FPE_FLTINV", FPE_FLTINV, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef FPE_FLTSUB
REGISTER_LONG_CONSTANT("FPE_FLTSUB", FPE_FLTSUB, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef SEGV_MAPERR
REGISTER_LONG_CONSTANT("SEGV_MAPERR", SEGV_MAPERR, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef SEGV_ACCERR
REGISTER_LONG_CONSTANT("SEGV_ACCERR", SEGV_ACCERR, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef BUS_ADRALN
REGISTER_LONG_CONSTANT("BUS_ADRALN", BUS_ADRALN, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef BUS_ADRERR
REGISTER_LONG_CONSTANT("BUS_ADRERR", BUS_ADRERR, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef BUS_OBJERR
REGISTER_LONG_CONSTANT("BUS_OBJERR", BUS_OBJERR, CONST_CS | CONST_PERSISTENT);
#endif
+#endif /* HAVE_SIGWAITINFO && HAVE_SIGTIMEDWAIT */
/* }}} */
}
@@ -537,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
@@ -854,6 +922,14 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
}
+ /*
+ * sigtimedwait and sigwaitinfo can return 0 on success on some
+ * platforms, e.g. NetBSD
+ */
+ if (!signo && siginfo.si_signo) {
+ signo = siginfo.si_signo;
+ }
+
if (signo > 0 && user_siginfo) {
if (Z_TYPE_P(user_siginfo) != IS_ARRAY) {
zval_dtor(user_siginfo);
diff --git a/ext/pcntl/tests/001.phpt b/ext/pcntl/tests/001.phpt
index d83cae446..fb1006e4b 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/002.phpt b/ext/pcntl/tests/002.phpt
index ac0ca9f75..3cec8833f 100644
--- a/ext/pcntl/tests/002.phpt
+++ b/ext/pcntl/tests/002.phpt
@@ -5,6 +5,7 @@ pcntl: pcntl_sigprocmask(), pcntl_sigwaitinfo(), pcntl_sigtimedwait()
if (!extension_loaded('pcntl')) die('skip pcntl extension not available');
elseif (!extension_loaded('posix')) die('skip posix extension not available');
elseif (!function_exists('pcntl_sigwaitinfo') or !function_exists('pcntl_sigtimedwait')) die('skip required functionality is not available');
+ elseif (!defined('CLD_EXITED')) die('skip CLD_EXITED not defined');
?>
--FILE--
<?php
@@ -67,7 +68,7 @@ if ($pid == -1) {
var_dump(pcntl_sigtimedwait(array(SIGTERM), $signo, PHP_INT_MAX, PHP_INT_MAX));
} else {
$siginfo = NULL;
- pcntl_sigtimedwait(array(SIGINT), $siginfo, PHP_INT_MAX, 999999999);
+ pcntl_sigtimedwait(array(SIGINT), $siginfo, 3600, 0);
exit;
}
diff --git a/ext/pcntl/tests/003.phpt b/ext/pcntl/tests/003.phpt
new file mode 100644
index 000000000..012277d25
--- /dev/null
+++ b/ext/pcntl/tests/003.phpt
@@ -0,0 +1,32 @@
+--TEST--
+pcntl: SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK
+--SKIPIF--
+<?php
+ if (!extension_loaded('pcntl')) die('skip pcntl extension not available');
+ elseif (!extension_loaded('posix')) die('skip posix extension not available');
+ elseif (!function_exists('pcntl_sigwaitinfo') or !function_exists('pcntl_sigtimedwait')) die('skip required functionality is not available');
+?>
+--FILE--
+<?php
+
+pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD,SIGTERM), $old);
+var_dump(count($old));
+pcntl_sigprocmask(SIG_BLOCK, array(SIGINT), $old);
+var_dump(count($old));
+pcntl_sigprocmask(SIG_UNBLOCK, array(SIGINT), $old);
+var_dump(count($old));
+pcntl_sigprocmask(SIG_SETMASK, array(SIGINT), $old);
+var_dump(count($old));
+pcntl_sigprocmask(SIG_SETMASK, array(), $old);
+var_dump(count($old));
+pcntl_sigprocmask(SIG_SETMASK, array(), $old);
+var_dump(count($old));
+
+?>
+--EXPECT--
+int(0)
+int(2)
+int(3)
+int(2)
+int(1)
+int(0)
diff --git a/ext/pcntl/tests/bug47566.phpt b/ext/pcntl/tests/bug47566.phpt
new file mode 100644
index 000000000..8a69e6bc7
--- /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)
diff --git a/ext/pcntl/tests/signal_closure_handler.phpt b/ext/pcntl/tests/signal_closure_handler.phpt
index 84147b5ba..438e05159 100755
--- a/ext/pcntl/tests/signal_closure_handler.phpt
+++ b/ext/pcntl/tests/signal_closure_handler.phpt
@@ -20,7 +20,6 @@ echo "Done!\n";
?>
--EXPECTF--
-Deprecated: Ticks is deprecated and will be removed in PHP 6 in %s on line %d
Start!
Signal handler called!
Done!