lbarnaud                Tue Jul 29 16:46:11 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/pcntl/tests    pcntl_signal_dispatch.phpt 

  Modified files:              
    /php-src/ext/pcntl  pcntl.c php_pcntl.h 
  Log:
  MFH: Added pcntl_signal_dispatch()
  [DOC] pcntl_signal_dispatch() allows to dispatch pending signals to registered
  signal handler functions on-demand. This allows to use pcntl_signal() without
  ticks.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pcntl/pcntl.c?r1=1.48.2.2.2.4.2.5&r2=1.48.2.2.2.4.2.6&diff_format=u
Index: php-src/ext/pcntl/pcntl.c
diff -u php-src/ext/pcntl/pcntl.c:1.48.2.2.2.4.2.5 
php-src/ext/pcntl/pcntl.c:1.48.2.2.2.4.2.6
--- php-src/ext/pcntl/pcntl.c:1.48.2.2.2.4.2.5  Mon Jun 30 13:15:03 2008
+++ php-src/ext/pcntl/pcntl.c   Tue Jul 29 16:46:11 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: pcntl.c,v 1.48.2.2.2.4.2.5 2008/06/30 13:15:03 felipe Exp $ */
+/* $Id: pcntl.c,v 1.48.2.2.2.4.2.6 2008/07/29 16:46:11 lbarnaud Exp $ */
 
 #define PCNTL_DEBUG 0
 
@@ -134,6 +134,7 @@
        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_dispatch,   arginfo_pcntl_void)
        PHP_FE(pcntl_wifexited,         arginfo_pcntl_wifexited)
        PHP_FE(pcntl_wifstopped,        arginfo_pcntl_wifstopped)
        PHP_FE(pcntl_wifsignaled,       arginfo_pcntl_wifsignaled)
@@ -173,7 +174,7 @@
 #endif
 
 static void pcntl_signal_handler(int);
-static void pcntl_tick_handler();
+static void pcntl_signal_dispatch();
   
 void php_register_signal_constants(INIT_FUNC_ARGS)
 {
@@ -262,7 +263,7 @@
 PHP_MINIT_FUNCTION(pcntl)
 {
        php_register_signal_constants(INIT_FUNC_ARGS_PASSTHRU);
-       php_add_tick_function(pcntl_tick_handler);
+       php_add_tick_function(pcntl_signal_dispatch);
 
        return SUCCESS;
 }
@@ -644,6 +645,15 @@
 }
 /* }}} */
 
+/* {{{ proto bool pcntl_signal_dispatch()
+   Dispatch signals to signal handlers */
+PHP_FUNCTION(pcntl_signal_dispatch)
+{
+       pcntl_signal_dispatch();
+       RETURN_TRUE;
+}
+/* }}} */
+
 #ifdef HAVE_GETPRIORITY
 /* {{{ proto int pcntl_getpriority([int pid [, int process_identifier]])
    Get the priority of any process */
@@ -747,7 +757,7 @@
        PCNTL_G(tail) = psig;
 }
 
-void pcntl_tick_handler()
+void pcntl_signal_dispatch()
 {
        zval *param, **handle, *retval;
        struct php_pcntl_pending_signal *queue, *next;
http://cvs.php.net/viewvc.cgi/php-src/ext/pcntl/php_pcntl.h?r1=1.20.2.1.2.1.2.2&r2=1.20.2.1.2.1.2.3&diff_format=u
Index: php-src/ext/pcntl/php_pcntl.h
diff -u php-src/ext/pcntl/php_pcntl.h:1.20.2.1.2.1.2.2 
php-src/ext/pcntl/php_pcntl.h:1.20.2.1.2.1.2.3
--- php-src/ext/pcntl/php_pcntl.h:1.20.2.1.2.1.2.2      Thu Jan  3 16:20:32 2008
+++ php-src/ext/pcntl/php_pcntl.h       Tue Jul 29 16:46:11 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcntl.h,v 1.20.2.1.2.1.2.2 2008/01/03 16:20:32 nlopess Exp $ */
+/* $Id: php_pcntl.h,v 1.20.2.1.2.1.2.3 2008/07/29 16:46:11 lbarnaud Exp $ */
 
 #ifndef PHP_PCNTL_H
 #define PHP_PCNTL_H
@@ -44,6 +44,7 @@
 PHP_FUNCTION(pcntl_wtermsig);
 PHP_FUNCTION(pcntl_wstopsig);
 PHP_FUNCTION(pcntl_signal);
+PHP_FUNCTION(pcntl_signal_dispatch);
 PHP_FUNCTION(pcntl_exec);
 #ifdef HAVE_GETPRIORITY
 PHP_FUNCTION(pcntl_getpriority);

http://cvs.php.net/viewvc.cgi/php-src/ext/pcntl/tests/pcntl_signal_dispatch.phpt?view=markup&rev=1.1
Index: php-src/ext/pcntl/tests/pcntl_signal_dispatch.phpt
+++ php-src/ext/pcntl/tests/pcntl_signal_dispatch.phpt
--TEST--
pcnt_signal_dispatch()
--SKIPIF--
<?php
        if (!extension_loaded("pcntl")) print "skip"; 
        if (!function_exists("pcntl_signal")) print "skip pcntl_signal() not 
available";
        if (!function_exists("pcntl_signal_dispatch")) print "skip 
pcntl_signal_dispatch() not available";
        if (!function_exists("posix_kill")) print "skip posix_kill() not 
available";
        if (!function_exists("posix_getpid")) print "skip posix_getpid() not 
available";
?>
--FILE--
<?php

pcntl_signal(SIGTERM, function ($signo) { echo "Signal handler called!\n"; });

echo "Start!\n";
posix_kill(posix_getpid(), SIGTERM);
$i = 0; // dummy
pcntl_signal_dispatch();
echo "Done!\n";

?>
--EXPECTF--
Start!
Signal handler called!
Done!



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to