summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_signal.h
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-01-17 20:00:00 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-01-17 20:00:00 +0300
commit16cbf3c076a0aca6d47adaf3f719493674cf2363 (patch)
treee6530480020f62a2bdbf249988ec3e2a751d3927 /src/nxt_signal.h
downloadunit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.gz
unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.bz2
Initial version.
Diffstat (limited to 'src/nxt_signal.h')
-rw-r--r--src/nxt_signal.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/nxt_signal.h b/src/nxt_signal.h
new file mode 100644
index 00000000..4141f39f
--- /dev/null
+++ b/src/nxt_signal.h
@@ -0,0 +1,74 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) NGINX, Inc.
+ */
+
+#ifndef _NXT_UNIX_SIGNAL_H_INCLUDED_
+#define _NXT_UNIX_SIGNAL_H_INCLUDED_
+
+
+typedef struct nxt_event_sig_s nxt_event_sig_t;
+
+struct nxt_event_sig_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_event_sig_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_event_sig_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_UNIX_SIGNAL_H_INCLUDED_ */