xref: /unit/src/nxt_signal.h (revision 0)
1*0Sigor@sysoev.ru 
2*0Sigor@sysoev.ru /*
3*0Sigor@sysoev.ru  * Copyright (C) Igor Sysoev
4*0Sigor@sysoev.ru  * Copyright (C) NGINX, Inc.
5*0Sigor@sysoev.ru  */
6*0Sigor@sysoev.ru 
7*0Sigor@sysoev.ru #ifndef _NXT_UNIX_SIGNAL_H_INCLUDED_
8*0Sigor@sysoev.ru #define _NXT_UNIX_SIGNAL_H_INCLUDED_
9*0Sigor@sysoev.ru 
10*0Sigor@sysoev.ru 
11*0Sigor@sysoev.ru typedef struct nxt_event_sig_s  nxt_event_sig_t;
12*0Sigor@sysoev.ru 
13*0Sigor@sysoev.ru struct nxt_event_sig_s {
14*0Sigor@sysoev.ru     int                         signo;
15*0Sigor@sysoev.ru     nxt_work_handler_t          handler;
16*0Sigor@sysoev.ru     const char                  *name;
17*0Sigor@sysoev.ru };
18*0Sigor@sysoev.ru 
19*0Sigor@sysoev.ru #define nxt_event_signal(sig, handler)                                        \
20*0Sigor@sysoev.ru     { sig, handler, #sig }
21*0Sigor@sysoev.ru 
22*0Sigor@sysoev.ru #define nxt_event_signal_end                                                  \
23*0Sigor@sysoev.ru     { 0, NULL, NULL }
24*0Sigor@sysoev.ru 
25*0Sigor@sysoev.ru 
26*0Sigor@sysoev.ru typedef struct {
27*0Sigor@sysoev.ru     /* Used by epoll and eventport. */
28*0Sigor@sysoev.ru     nxt_work_handler_t          handler;
29*0Sigor@sysoev.ru 
30*0Sigor@sysoev.ru     const nxt_event_sig_t       *sigev;
31*0Sigor@sysoev.ru     sigset_t                    sigmask;
32*0Sigor@sysoev.ru 
33*0Sigor@sysoev.ru #if (NXT_THREADS)
34*0Sigor@sysoev.ru     /* Used by the signal thread. */
35*0Sigor@sysoev.ru     nxt_pid_t                   process;
36*0Sigor@sysoev.ru     nxt_thread_handle_t         thread;
37*0Sigor@sysoev.ru #endif
38*0Sigor@sysoev.ru } nxt_event_signals_t;
39*0Sigor@sysoev.ru 
40*0Sigor@sysoev.ru 
41*0Sigor@sysoev.ru nxt_event_signals_t *nxt_event_engine_signals(const nxt_event_sig_t *sigev);
42*0Sigor@sysoev.ru 
43*0Sigor@sysoev.ru #if (NXT_THREADS)
44*0Sigor@sysoev.ru 
45*0Sigor@sysoev.ru #define                                                                       \
46*0Sigor@sysoev.ru nxt_event_engine_signals_start(engine)                                        \
47*0Sigor@sysoev.ru     nxt_signal_thread_start(engine)
48*0Sigor@sysoev.ru 
49*0Sigor@sysoev.ru #define                                                                       \
50*0Sigor@sysoev.ru nxt_event_engine_signals_stop(engine)                                         \
51*0Sigor@sysoev.ru     nxt_signal_thread_stop(engine)
52*0Sigor@sysoev.ru 
53*0Sigor@sysoev.ru 
54*0Sigor@sysoev.ru NXT_EXPORT nxt_int_t nxt_signal_thread_start(nxt_event_engine_t *engine);
55*0Sigor@sysoev.ru NXT_EXPORT void nxt_signal_thread_stop(nxt_event_engine_t *engine);
56*0Sigor@sysoev.ru 
57*0Sigor@sysoev.ru #else /* !(NXT_THREADS) */
58*0Sigor@sysoev.ru 
59*0Sigor@sysoev.ru #define                                                                       \
60*0Sigor@sysoev.ru nxt_event_engine_signals_start(engine)                                        \
61*0Sigor@sysoev.ru     nxt_signal_handlers_start(engine)
62*0Sigor@sysoev.ru 
63*0Sigor@sysoev.ru #define                                                                       \
64*0Sigor@sysoev.ru nxt_event_engine_signals_stop(engine)                                         \
65*0Sigor@sysoev.ru     nxt_signal_handlers_stop(engine)
66*0Sigor@sysoev.ru 
67*0Sigor@sysoev.ru 
68*0Sigor@sysoev.ru NXT_EXPORT nxt_int_t nxt_signal_handlers_start(nxt_event_engine_t *engine);
69*0Sigor@sysoev.ru NXT_EXPORT void nxt_signal_handlers_stop(nxt_event_engine_t *engine);
70*0Sigor@sysoev.ru 
71*0Sigor@sysoev.ru #endif
72*0Sigor@sysoev.ru 
73*0Sigor@sysoev.ru 
74*0Sigor@sysoev.ru #endif /* _NXT_UNIX_SIGNAL_H_INCLUDED_ */
75