Back to index

php5  5.3.10
php_signal.c
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Author: Jason Greene <jason@inetgurus.net>                           |
00016    +----------------------------------------------------------------------+
00017 */
00018 
00019 /* $Id: php_signal.c 321634 2012-01-01 13:15:04Z felipe $ */
00020 
00021 #include "php_signal.h"
00022 
00023 /* php_signal using sigaction is derrived from Advanced Programing
00024  * in the Unix Environment by W. Richard Stevens p 298. */
00025 Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all)
00026 {
00027        struct sigaction act,oact;
00028        act.sa_handler = func;
00029        if (mask_all) {
00030               sigfillset(&act.sa_mask);
00031        } else {
00032               sigemptyset(&act.sa_mask);
00033        }
00034        act.sa_flags = 0;
00035        if (signo == SIGALRM || (! restart)) {
00036 #ifdef SA_INTERRUPT
00037               act.sa_flags |= SA_INTERRUPT; /* SunOS */
00038 #endif
00039        } else {
00040 #ifdef SA_RESTART
00041               act.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */
00042 #endif
00043        }
00044        if (sigaction(signo, &act, &oact) < 0)
00045               return SIG_ERR;
00046  
00047        return oact.sa_handler;
00048 }
00049 
00050 Sigfunc *php_signal(int signo, Sigfunc *func, int restart)
00051 {
00052        return php_signal4(signo, func, restart, 0);
00053 }
00054 
00055 /*
00056  * Local variables:
00057  * tab-width: 4
00058  * c-basic-offset: 4
00059  * End:
00060  * vim600: noet sw=4 ts=4 fdm=marker
00061  * vim<600: noet sw=4 ts=4
00062  */