ZEND_ARG_INFO(0, restart_syscalls)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_signal_get_handler, 0, 0, 1)
+ ZEND_ARG_INFO(0, signo)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_sigprocmask, 0, 0, 2)
ZEND_ARG_INFO(0, how)
ZEND_ARG_INFO(0, set)
PHP_FE(pcntl_waitpid, arginfo_pcntl_waitpid)
PHP_FE(pcntl_wait, arginfo_pcntl_wait)
PHP_FE(pcntl_signal, arginfo_pcntl_signal)
+ PHP_FE(pcntl_signal_get_handler, arginfo_pcntl_signal_get_handler)
PHP_FE(pcntl_signal_dispatch, arginfo_pcntl_void)
PHP_FE(pcntl_wifexited, arginfo_pcntl_wifexited)
PHP_FE(pcntl_wifstopped, arginfo_pcntl_wifstopped)
php_error_docref(NULL, E_WARNING, "Error assigning signal");
RETURN_FALSE;
}
- zend_hash_index_del(&PCNTL_G(php_signal_table), signo);
+ zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle);
RETURN_TRUE;
}
}
/* }}} */
+/* {{{ proto bool pcntl_signal_get_handler(int signo)
+ Gets signal handler */
+PHP_FUNCTION(pcntl_signal_get_handler)
+{
+ zval *prev_handle;
+ zend_long signo;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &signo) == FAILURE) {
+ return;
+ }
+
+ if (signo < 1 || signo > 32) {
+ php_error_docref(NULL, E_WARNING, "Invalid signal");
+ RETURN_FALSE;
+ }
+
+ if ((prev_handle = zend_hash_index_find(&PCNTL_G(php_signal_table), signo)) != NULL) {
+ RETURN_ZVAL(prev_handle, 1, 0);
+ } else {
+ RETURN_LONG((long)SIG_DFL);
+ }
+}
+
/* {{{ proto bool pcntl_signal_dispatch()
Dispatch signals to signal handlers */
PHP_FUNCTION(pcntl_signal_dispatch)
--- /dev/null
+--TEST--
+pcntl_signal()
+--SKIPIF--
+<?php if (!extension_loaded("pcntl")) print "skip"; ?>
+<?php if (!extension_loaded("posix")) die("skip posix extension not available"); ?>
+--FILE--
+<?php
+var_dump(pcntl_signal_get_handler(SIGUSR1));
+
+function pcntl_test($signo) {}
+pcntl_signal(SIGUSR1, 'pcntl_test');
+var_dump(pcntl_signal_get_handler(SIGUSR1));
+
+pcntl_signal(SIGUSR1, SIG_IGN);
+var_dump(pcntl_signal_get_handler(SIGUSR1));
+
+pcntl_signal(SIGUSR1, SIG_DFL);
+var_dump(pcntl_signal_get_handler(SIGUSR1));
+
+posix_kill(posix_getpid(), SIGUSR1);
+pcntl_signal_dispatch();
+
+echo "ok\n";
+?>
+--EXPECTF--
+int(0)
+string(10) "pcntl_test"
+int(1)
+int(0)
+User defined signal 1
+
+Termsig=10