chiark / gitweb /
basic: mark unused variable as such
[elogind.git] / src / basic / signal-util.h
1 #pragma once
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2010-2015 Lennart Poettering
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <signal.h>
23
24 #include "macro.h"
25
26 int reset_all_signal_handlers(void);
27 int reset_signal_mask(void);
28
29 int ignore_signals(int sig, ...);
30 #if 0 /// UNNEEDED by elogind
31 int default_signals(int sig, ...);
32 int sigaction_many(const struct sigaction *sa, ...);
33 #endif // 0
34
35 int sigset_add_many(sigset_t *ss, ...);
36 int sigprocmask_many(int how, sigset_t *old, ...);
37
38 const char *signal_to_string(int i) _const_;
39 int signal_from_string(const char *s) _pure_;
40
41 int signal_from_string_try_harder(const char *s);
42 #if 0 /// UNNEEDED by elogind
43
44 void nop_signal_handler(int sig);
45 #endif // 0
46
47 static inline void block_signals_reset(sigset_t *ss) {
48         assert_se(sigprocmask(SIG_SETMASK, ss, NULL) >= 0);
49 }
50
51 #define BLOCK_SIGNALS(...)                                                        \
52         _cleanup_(block_signals_reset) _unused_ sigset_t _saved_sigset = ({       \
53                 sigset_t t;                                                       \
54                 assert_se(sigprocmask_many(SIG_BLOCK, &t, __VA_ARGS__, -1) >= 0); \
55                 t;                                                                \
56         })