lbarnaud                Mon Nov 10 05:56:23 2008 UTC

  Modified files:              
    /php-src/ext/pcntl  pcntl.c php_signal.h 
    /php-src/ext/pcntl/tests    002.phpt 
  Log:
  Added the oldset parameter to pcntl_sigprocmask().
  Already documented.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pcntl/pcntl.c?r1=1.69&r2=1.70&diff_format=u
Index: php-src/ext/pcntl/pcntl.c
diff -u php-src/ext/pcntl/pcntl.c:1.69 php-src/ext/pcntl/pcntl.c:1.70
--- php-src/ext/pcntl/pcntl.c:1.69      Sun Nov  2 21:10:10 2008
+++ php-src/ext/pcntl/pcntl.c   Mon Nov 10 05:56:22 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: pcntl.c,v 1.69 2008/11/02 21:10:10 felipe Exp $ */
+/* $Id: pcntl.c,v 1.70 2008/11/10 05:56:22 lbarnaud Exp $ */
 
 #define PCNTL_DEBUG 0
 
@@ -76,6 +76,7 @@
 ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_sigprocmask, 0, 0, 2)
        ZEND_ARG_INFO(0, how)
        ZEND_ARG_INFO(0, set)
+       ZEND_ARG_INFO(1, oldset)
 ZEND_END_ARG_INFO()
 
 static
@@ -760,20 +761,20 @@
 /* }}} */
 
 #ifdef HAVE_SIGPROCMASK
-/* {{{ proto bool pcntl_sigprocmask(int how, array set)
+/* {{{ proto bool pcntl_sigprocmask(int how, array set[, array &oldset])
    Examine and change blocked signals */
 PHP_FUNCTION(pcntl_sigprocmask)
 {
        long          how, signo;
-       zval         *user_set, **user_signo;
-       sigset_t      set;
+       zval         *user_set, *user_oldset = NULL, **user_signo;
+       sigset_t      set, oldset;
        HashPosition  pos;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la", &how, 
&user_set) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la|z", &how, 
&user_set, &user_oldset) == FAILURE) {
                return;
        }
 
-       if (sigemptyset(&set) != 0) {
+       if (sigemptyset(&set) != 0 || sigemptyset(&oldset) != 0) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
strerror(errno));
                RETURN_FALSE;
        }
@@ -793,11 +794,26 @@
                zend_hash_move_forward_ex(Z_ARRVAL_P(user_set), &pos);
        }
 
-       if (sigprocmask(how, &set, NULL) != 0) {
+       if (sigprocmask(how, &set, &oldset) != 0) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
strerror(errno));
                RETURN_FALSE;
        }
 
+       if (user_oldset != NULL) {
+               if (Z_TYPE_P(user_oldset) != IS_ARRAY) {
+                       zval_dtor(user_oldset);
+                       array_init(user_oldset);
+               } else {
+                       zend_hash_clean(Z_ARRVAL_P(user_oldset));
+               }
+               for (signo = 1; signo < MAX(NSIG-1, SIGRTMAX); ++signo) {
+                       if (sigismember(&oldset, signo) != 1) {
+                               continue;
+                       }
+                       add_next_index_long(user_oldset, signo);
+               }
+       }
+
        RETURN_TRUE;
 }
 /* }}} */
@@ -859,6 +875,8 @@
                if (Z_TYPE_P(user_siginfo) != IS_ARRAY) {
                        zval_dtor(user_siginfo);
                        array_init(user_siginfo);
+               } else {
+                       zend_hash_clean(Z_ARRVAL_P(user_siginfo));
                }
                add_ascii_assoc_long_ex(user_siginfo, "signo", sizeof("signo"), 
siginfo.si_signo);
                add_ascii_assoc_long_ex(user_siginfo, "errno", sizeof("errno"), 
siginfo.si_errno);
http://cvs.php.net/viewvc.cgi/php-src/ext/pcntl/php_signal.h?r1=1.12&r2=1.13&diff_format=u
Index: php-src/ext/pcntl/php_signal.h
diff -u php-src/ext/pcntl/php_signal.h:1.12 php-src/ext/pcntl/php_signal.h:1.13
--- php-src/ext/pcntl/php_signal.h:1.12 Mon Dec 31 07:12:12 2007
+++ php-src/ext/pcntl/php_signal.h      Mon Nov 10 05:56:22 2008
@@ -16,12 +16,19 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_signal.h,v 1.12 2007/12/31 07:12:12 sebastian Exp $ */
+/* $Id: php_signal.h,v 1.13 2008/11/10 05:56:22 lbarnaud Exp $ */
 
 #include <signal.h>
 #ifndef PHP_SIGNAL_H
 #define PHP_SIGNAL_H
 
+#ifndef NSIG
+# define NSIG 32
+#endif
+#ifndef SIGRTMAX
+# define SIGRTMAX 64
+#endif
+
 typedef void Sigfunc(int);
 Sigfunc *php_signal(int signo, Sigfunc *func, int restart);
 
http://cvs.php.net/viewvc.cgi/php-src/ext/pcntl/tests/002.phpt?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/pcntl/tests/002.phpt
diff -u php-src/ext/pcntl/tests/002.phpt:1.4 
php-src/ext/pcntl/tests/002.phpt:1.5
--- php-src/ext/pcntl/tests/002.phpt:1.4        Fri Sep 12 12:17:48 2008
+++ php-src/ext/pcntl/tests/002.phpt    Mon Nov 10 05:56:22 2008
@@ -14,6 +14,11 @@
        die('failed');
 } else if ($pid) {
        pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD,(string)SIGTERM));
+       $oldset = array();
+       pcntl_sigprocmask(SIG_BLOCK, array(), $oldset);
+       var_dump(in_array(SIGCHLD, $oldset));
+       var_dump(in_array(SIGTERM, $oldset));
+
        posix_kill(posix_getpid(), SIGTERM);
        $signo = pcntl_sigwaitinfo(array(SIGTERM), $siginfo);
        echo "signo == SIGTERM\n";
@@ -68,6 +73,8 @@
 
 ?>
 --EXPECTF--
+bool(true)
+bool(true)
 signo == SIGTERM
 bool(true)
 code === SI_USER || SI_NOINFO



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

Reply via email to