Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 105 lines (88 sloc) 3.615 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;
58 int blocked; /* 0==TRUE, -1==FALSE */
59 int running; /* in signal handler execution */
60 int active; /* internal signal handling is enabled */
61 int initialized; /* memory initialized */
62 zend_bool check; /* check for replaced handlers on shutdown */
63 zend_signal_entry_t handlers[NSIG];
64 zend_signal_queue_t pstorage[ZEND_SIGNAL_QUEUE_SIZE], *phead, *ptail, *pavail; /* pending queue */
65 } zend_signal_globals_t;
66
67 #ifdef ZTS
68 # define SIGG(v) TSRMG(zend_signal_globals_id, zend_signal_globals_t *, v)
69 BEGIN_EXTERN_C()
70 ZEND_API extern int zend_signal_globals_id;
71 END_EXTERN_C()
72 #else /* ZTS */
73 # define SIGG(v) (zend_signal_globals.v)
74 extern ZEND_API zend_signal_globals_t zend_signal_globals;
75 #endif /* not ZTS */
76
77 # define SIGNAL_BEGIN_CRITICAL() sigset_t oldmask; \
78 zend_sigprocmask(SIG_BLOCK, &global_sigmask, &oldmask);
79 # define SIGNAL_END_CRITICAL() zend_sigprocmask(SIG_SETMASK, &oldmask, NULL);
80
81 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
82 ZEND_API void zend_signal_handler_unblock();
9398751 Zend Signal Handling (see RFC: https://wiki.php.net/rfc/zendsignals)
Ilia Alshanetsky authored
83 void zend_signal_activate(TSRMLS_D);
84 void zend_signal_deactivate(TSRMLS_D);
85 void zend_signal_startup();
86 void zend_signal_shutdown(TSRMLS_D);
87 ZEND_API int zend_signal(int signo, void (*handler)(int) TSRMLS_DC);
88 ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact TSRMLS_DC);
89
90 #ifdef ZTS
91 #define zend_sigprocmask(signo, set, oldset) tsrm_sigmask((signo), (set), (oldset))
92 #else
93 #define zend_sigprocmask(signo, set, oldset) sigprocmask((signo), (set), (oldset))
94 #endif
95
96 #endif /* ZEND_SIGNAL_H */
97
98 /*
99 * Local variables:
100 * tab-width: 4
101 * c-basic-offset: 4
102 * indent-tabs-mode: t
103 * End:
104 */
Something went wrong with that request. Please try again.