/* php_signal using sigaction is derived from Advanced Programing * in the Unix Environment by W. Richard Stevens p 298. */ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all) { struct sigaction act,oact; #ifdef ZEND_SIGNALS TSRMLS_FETCH(); #endif act.sa_handler = func; if (mask_all) { sigfillset(&act.sa_mask); } else { sigemptyset(&act.sa_mask); } act.sa_flags = 0; if (signo == SIGALRM || (! restart)) { #ifdef SA_INTERRUPT act.sa_flags |= SA_INTERRUPT; /* SunOS */ #endif } else { #ifdef SA_RESTART act.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */ #endif } #ifdef ZEND_SIGNALS if (zend_sigaction(signo, &act, &oact TSRMLS_CC) < 0) #else if (sigaction(signo, &act, &oact) < 0) #endif { return SIG_ERR; } return oact.sa_handler; }
/* {{{ zend_signal * Register a signal handler that will be deferred in critical sections */ ZEND_API int zend_signal(int signo, void (*handler)(int)) { struct sigaction sa = {{0}}; sa.sa_flags = 0; sa.sa_handler = handler; sa.sa_mask = global_sigmask; return zend_sigaction(signo, &sa, NULL); }
/* {{{ zend_signal * Register a signal handler that will be deferred in critical sections */ ZEND_API int zend_signal(int signo, void (*handler)(int)) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_flags = 0; sa.sa_handler = handler; sa.sa_mask = global_sigmask; return zend_sigaction(signo, &sa, NULL); }
/* php_signal using sigaction is derived from Advanced Programing * in the Unix Environment by W. Richard Stevens p 298. */ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all) { struct sigaction act,oact; #ifdef HAVE_STRUCT_SIGINFO_T act.sa_sigaction = func; #else act.sa_handler = func; #endif if (mask_all) { sigfillset(&act.sa_mask); } else { sigemptyset(&act.sa_mask); } act.sa_flags = 0; #ifdef HAVE_STRUCT_SIGINFO_T act.sa_flags |= SA_SIGINFO; #endif if (signo == SIGALRM || (! restart)) { #ifdef SA_INTERRUPT act.sa_flags |= SA_INTERRUPT; /* SunOS */ #endif } else { #ifdef SA_RESTART act.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */ #endif } if (zend_sigaction(signo, &act, &oact) < 0) { return (Sigfunc*)SIG_ERR; } #ifdef HAVE_STRUCT_SIGINFO_T return oact.sa_sigaction; #else return oact.sa_handler; #endif }