Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 109 lines (92 sloc) 4.011 kB
9398751 Zend Signal Handling (see RFC: https://wiki.php.net/rfc/zendsignals)
Ilia Alshanetsky authored
1 /*
2 +----------------------------------------------------------------------+
3 | Zend Signal Handling |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2008 The PHP Group |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Lucas Nealan <lucas@php.net> |
16 | Arnaud Le Blanc <lbarnaud@php.net> |
17 +----------------------------------------------------------------------+
18
19 */
20
21 /* $Id$ */
22
23 #ifndef ZEND_SIGNAL_H
24 #define ZEND_SIGNAL_H
25
26 #ifdef HAVE_SIGNAL_H
27 #include <signal.h>
28 #endif
29
30 #ifndef NSIG
31 #define NSIG 65
32 #endif
33
34 #ifndef ZEND_SIGNAL_QUEUE_SIZE
35 #define ZEND_SIGNAL_QUEUE_SIZE 32
36 #endif
37
38 /* Signal structs */
39 typedef struct _zend_signal_entry_t {
40 int flags; /* sigaction style flags */
41 void* handler; /* signal handler or context */
42 } zend_signal_entry_t;
43
44 typedef struct _zend_signal_t {
45 int signo;
46 siginfo_t *siginfo;
47 void* context;
48 } zend_signal_t;
49
50 typedef struct _zend_signal_queue_t {
51 zend_signal_t zend_signal;
52 struct _zend_signal_queue_t *next;
53 } zend_signal_queue_t;
54
55 /* Signal Globals */
56 typedef struct _zend_signal_globals_t {
57 int depth;
fd5a756 @laruence Revive Zend Signals handler (and fixed bug #61083)
laruence authored
58 int blocked; /* 1==TRUE, 0==FALSE */
9398751 Zend Signal Handling (see RFC: https://wiki.php.net/rfc/zendsignals)
Ilia Alshanetsky authored
59 int running; /* in signal handler execution */
60 int active; /* internal signal handling is enabled */
61 zend_bool check; /* check for replaced handlers on shutdown */
62 zend_signal_entry_t handlers[NSIG];
63 zend_signal_queue_t pstorage[ZEND_SIGNAL_QUEUE_SIZE], *phead, *ptail, *pavail; /* pending queue */
64 } zend_signal_globals_t;
65
66 #ifdef ZTS
76081df @weltling using pointer to the tsrm ls cache instead of a function call
weltling authored
67 # define SIGG(v) ZEND_TSRMG(zend_signal_globals_id, zend_signal_globals_t *, v)
9398751 Zend Signal Handling (see RFC: https://wiki.php.net/rfc/zendsignals)
Ilia Alshanetsky authored
68 BEGIN_EXTERN_C()
69 ZEND_API extern int zend_signal_globals_id;
70 END_EXTERN_C()
b31c124 @laruence Fixed bug #60627 (httpd.worker segfault on startup with php_value)
laruence authored
71 # define ZEND_SIGNAL_BLOCK_INTERRUPUTIONS() if (EXPECTED(zend_signal_globals_id)) { SIGG(depth)++; }
fd5a756 @laruence Revive Zend Signals handler (and fixed bug #61083)
laruence authored
72 # define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (EXPECTED(zend_signal_globals_id) && UNEXPECTED(((SIGG(depth)--) == SIGG(blocked)))) { zend_signal_handler_unblock(); }
9398751 Zend Signal Handling (see RFC: https://wiki.php.net/rfc/zendsignals)
Ilia Alshanetsky authored
73 #else /* ZTS */
74 # define SIGG(v) (zend_signal_globals.v)
75 extern ZEND_API zend_signal_globals_t zend_signal_globals;
b31c124 @laruence Fixed bug #60627 (httpd.worker segfault on startup with php_value)
laruence authored
76 # define ZEND_SIGNAL_BLOCK_INTERRUPUTIONS() SIGG(depth)++;
fd5a756 @laruence Revive Zend Signals handler (and fixed bug #61083)
laruence authored
77 # define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (((SIGG(depth)--) == SIGG(blocked))) { zend_signal_handler_unblock(); }
9398751 Zend Signal Handling (see RFC: https://wiki.php.net/rfc/zendsignals)
Ilia Alshanetsky authored
78 #endif /* not ZTS */
79
80 # define SIGNAL_BEGIN_CRITICAL() sigset_t oldmask; \
81 zend_sigprocmask(SIG_BLOCK, &global_sigmask, &oldmask);
82 # define SIGNAL_END_CRITICAL() zend_sigprocmask(SIG_SETMASK, &oldmask, NULL);
83
84 void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context);
0d49305 Expose zend_signal_handler_unblock() to DSO extensions to allow usage…
Dmitry Stogov authored
85 ZEND_API void zend_signal_handler_unblock();
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored
86 void zend_signal_activate(void);
87 void zend_signal_deactivate(void);
9398751 Zend Signal Handling (see RFC: https://wiki.php.net/rfc/zendsignals)
Ilia Alshanetsky authored
88 void zend_signal_startup();
fd5a756 @laruence Revive Zend Signals handler (and fixed bug #61083)
laruence authored
89 void zend_signal_init();
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored
90 void zend_signal_shutdown(void);
91 ZEND_API int zend_signal(int signo, void (*handler)(int));
92 ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact);
9398751 Zend Signal Handling (see RFC: https://wiki.php.net/rfc/zendsignals)
Ilia Alshanetsky authored
93
94 #ifdef ZTS
95 #define zend_sigprocmask(signo, set, oldset) tsrm_sigmask((signo), (set), (oldset))
96 #else
97 #define zend_sigprocmask(signo, set, oldset) sigprocmask((signo), (set), (oldset))
98 #endif
99
100 #endif /* ZEND_SIGNAL_H */
101
102 /*
103 * Local variables:
104 * tab-width: 4
105 * c-basic-offset: 4
106 * indent-tabs-mode: t
107 * End:
108 */
Something went wrong with that request. Please try again.