2001-06-12 16:54:25 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2004-01-08 16:18:22 +08:00
|
|
|
| PHP Version 5 |
|
2001-06-12 16:54:25 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2007-01-01 17:36:18 +08:00
|
|
|
| Copyright (c) 1997-2007 The PHP Group |
|
2001-06-12 16:54:25 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 20:51:34 +08:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2001-06-12 16:54:25 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 20:51:34 +08:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2001-06-12 16:54:25 +08:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2002-02-28 16:29:35 +08:00
|
|
|
| Author: Jason Greene <jason@inetgurus.net> |
|
2001-06-12 16:54:25 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2001-07-31 04:51:57 +08:00
|
|
|
/* $Id$ */
|
|
|
|
|
2001-06-12 16:54:25 +08:00
|
|
|
#include "php_signal.h"
|
|
|
|
|
2002-08-22 12:20:10 +08:00
|
|
|
/* php_signal using sigaction is derrived from Advanced Programing
|
2001-06-12 16:54:25 +08:00
|
|
|
* in the Unix Environment by W. Richard Stevens p 298. */
|
2002-08-22 12:20:10 +08:00
|
|
|
Sigfunc *php_signal(int signo, Sigfunc *func, int restart)
|
2001-06-12 16:54:25 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
struct sigaction act,oact;
|
|
|
|
act.sa_handler = func;
|
|
|
|
sigemptyset(&act.sa_mask);
|
|
|
|
act.sa_flags = 0;
|
2002-08-22 12:20:10 +08:00
|
|
|
if (signo == SIGALRM || (! restart)) {
|
2001-06-12 16:54:25 +08:00
|
|
|
#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 (sigaction(signo, &act, &oact) < 0)
|
|
|
|
return SIG_ERR;
|
|
|
|
|
|
|
|
return oact.sa_handler;
|
|
|
|
}
|
|
|
|
|