summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_signal.h
blob: 2194d1f408a8949f6afe3e8b1947865f41655caf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) NGINX, Inc.
 */

#ifndef _NXT_SIGNAL_H_INCLUDED_
#define _NXT_SIGNAL_H_INCLUDED_


struct nxt_sig_event_s {
    int                         signo;
    nxt_work_handler_t          handler;
    const char                  *name;
};

#define nxt_event_signal(sig, handler)                                        \
    { sig, handler, #sig }

#define nxt_event_signal_end                                                  \
    { 0, NULL, NULL }


typedef struct {
    /* Used by epoll and eventport. */
    nxt_work_handler_t          handler;

    const nxt_sig_event_t       *sigev;
    sigset_t                    sigmask;

#if (NXT_THREADS)
    /* Used by the signal thread. */
    nxt_pid_t                   process;
    nxt_thread_handle_t         thread;
#endif
} nxt_event_signals_t;


nxt_event_signals_t *nxt_event_engine_signals(const nxt_sig_event_t *sigev);

#if (NXT_THREADS)

#define                                                                       \
nxt_event_engine_signals_start(engine)                                        \
    nxt_signal_thread_start(engine)

#define                                                                       \
nxt_event_engine_signals_stop(engine)                                         \
    nxt_signal_thread_stop(engine)


NXT_EXPORT nxt_int_t nxt_signal_thread_start(nxt_event_engine_t *engine);
NXT_EXPORT void nxt_signal_thread_stop(nxt_event_engine_t *engine);

#else /* !(NXT_THREADS) */

#define                                                                       \
nxt_event_engine_signals_start(engine)                                        \
    nxt_signal_handlers_start(engine)

#define                                                                       \
nxt_event_engine_signals_stop(engine)                                         \
    nxt_signal_handlers_stop(engine)


NXT_EXPORT nxt_int_t nxt_signal_handlers_start(nxt_event_engine_t *engine);
NXT_EXPORT void nxt_signal_handlers_stop(nxt_event_engine_t *engine);

#endif


#endif /* _NXT_SIGNAL_H_INCLUDED_ */