xref: /unit/src/nxt_signal.h (revision 223:bf98efe2c55c)
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) NGINX, Inc.
5  */
6 
7 #ifndef _NXT_SIGNAL_H_INCLUDED_
8 #define _NXT_SIGNAL_H_INCLUDED_
9 
10 
11 struct nxt_sig_event_s {
12     int                         signo;
13     nxt_work_handler_t          handler;
14     const char                  *name;
15 };
16 
17 #define nxt_event_signal(sig, handler)                                        \
18     { sig, handler, #sig }
19 
20 #define nxt_event_signal_end                                                  \
21     { 0, NULL, NULL }
22 
23 
24 typedef struct {
25     /* Used by epoll and eventport. */
26     nxt_work_handler_t          handler;
27 
28     const nxt_sig_event_t       *sigev;
29     sigset_t                    sigmask;
30 
31     /* Used by the signal thread. */
32     nxt_pid_t                   process;
33     nxt_thread_handle_t         thread;
34 } nxt_event_signals_t;
35 
36 
37 nxt_event_signals_t *nxt_event_engine_signals(const nxt_sig_event_t *sigev);
38 
39 #define                                                                       \
40 nxt_event_engine_signals_start(engine)                                        \
41     nxt_signal_thread_start(engine)
42 
43 #define                                                                       \
44 nxt_event_engine_signals_stop(engine)                                         \
45     nxt_signal_thread_stop(engine)
46 
47 
48 NXT_EXPORT nxt_int_t nxt_signal_thread_start(nxt_event_engine_t *engine);
49 NXT_EXPORT void nxt_signal_thread_stop(nxt_event_engine_t *engine);
50 
51 
52 #endif /* _NXT_SIGNAL_H_INCLUDED_ */
53