]>
Commit | Line | Data |
---|---|---|
24882e06 LP |
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 | int default_signals(int sig, ...); | |
31 | int sigaction_many(const struct sigaction *sa, ...); | |
32 | ||
0c2c2a3a | 33 | int sigset_add_many(sigset_t *ss, ...); |
72c0a2c2 | 34 | int sigprocmask_many(int how, sigset_t *old, ...); |
24882e06 LP |
35 | |
36 | const char *signal_to_string(int i) _const_; | |
37 | int signal_from_string(const char *s) _pure_; | |
38 | ||
39 | int signal_from_string_try_harder(const char *s); | |
6bedfcbb LP |
40 | |
41 | void nop_signal_handler(int sig); | |
0c5eb056 LP |
42 | |
43 | static inline void block_signals_reset(sigset_t *ss) { | |
44 | assert_se(sigprocmask(SIG_SETMASK, ss, NULL) >= 0); | |
45 | } | |
46 | ||
7c9337da TA |
47 | #define BLOCK_SIGNALS(...) \ |
48 | _cleanup_(block_signals_reset) _unused_ sigset_t _saved_sigset = ({ \ | |
49 | sigset_t t; \ | |
0c5eb056 | 50 | assert_se(sigprocmask_many(SIG_BLOCK, &t, __VA_ARGS__, -1) >= 0); \ |
7c9337da | 51 | t; \ |
0c5eb056 | 52 | }) |
6eb7c172 LP |
53 | |
54 | static inline bool SIGNAL_VALID(int signo) { | |
55 | return signo > 0 && signo < _NSIG; | |
56 | } |