diff options
author | David Walker <dave@mudsite.com> | 2016-06-13 18:33:19 -0400 |
---|---|---|
committer | David Walker <dave@mudsite.com> | 2016-07-07 09:43:18 -0600 |
commit | f64388e8c1686948d88401ae9871c87cb012b65f (patch) | |
tree | 494dcf851dc7cc7317e666817f6b62fd7880dc6b /ext/pcntl/php_signal.c | |
parent | ab304579ff046426f281e9a95abea8d611e38e1c (diff) | |
download | php-git-f64388e8c1686948d88401ae9871c87cb012b65f.tar.gz |
pnctl_signal(): add siginfo to handler args
Feature will utilize already available siginfo parsing
and extend the handler for signals to provide an array
of the siginfo_t data.
RFC:https://wiki.php.net/rfc/additional-context-in-pcntl-signal-handler
Diffstat (limited to 'ext/pcntl/php_signal.c')
-rw-r--r-- | ext/pcntl/php_signal.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/pcntl/php_signal.c b/ext/pcntl/php_signal.c index a18e641d2a..2d98851bd6 100644 --- a/ext/pcntl/php_signal.c +++ b/ext/pcntl/php_signal.c @@ -29,13 +29,20 @@ 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 */ @@ -46,10 +53,14 @@ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all) #endif } if (zend_sigaction(signo, &act, &oact) < 0) { - return SIG_ERR; + return (Sigfunc*)SIG_ERR; } +#ifdef HAVE_STRUCT_SIGINFO_T + return oact.sa_sigaction; +#else return oact.sa_handler; +#endif } Sigfunc *php_signal(int signo, Sigfunc *func, int restart) |