Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_SIGNAL_H |
| 2 | #define _LINUX_SIGNAL_H |
| 3 | |
Oleg Nesterov | 1c3bea0 | 2014-10-13 15:53:33 -0700 | [diff] [blame] | 4 | #include <linux/bug.h> |
Ingo Molnar | e6d930b | 2017-02-03 23:43:50 +0100 | [diff] [blame] | 5 | #include <linux/signal_types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
Stephen Rothwell | 1477fcc | 2011-05-20 11:11:53 +1000 | [diff] [blame] | 7 | struct task_struct; |
| 8 | |
Dave Young | d33ed52 | 2010-03-10 15:23:59 -0800 | [diff] [blame] | 9 | /* for sysctl */ |
| 10 | extern int print_fatal_signals; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
James Hogan | ca9eb49 | 2016-02-08 18:43:50 +0000 | [diff] [blame] | 12 | #ifndef HAVE_ARCH_COPY_SIGINFO |
| 13 | |
| 14 | #include <linux/string.h> |
| 15 | |
| 16 | static inline void copy_siginfo(struct siginfo *to, struct siginfo *from) |
| 17 | { |
| 18 | if (from->si_code < 0) |
| 19 | memcpy(to, from, sizeof(*to)); |
| 20 | else |
| 21 | /* _sigchld is currently the largest know union member */ |
| 22 | memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld)); |
| 23 | } |
| 24 | |
| 25 | #endif |
| 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | /* |
| 28 | * Define some primitives to manipulate sigset_t. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __HAVE_ARCH_SIG_BITOPS |
| 32 | #include <linux/bitops.h> |
| 33 | |
| 34 | /* We don't use <linux/bitops.h> for these because there is no need to |
| 35 | be atomic. */ |
| 36 | static inline void sigaddset(sigset_t *set, int _sig) |
| 37 | { |
| 38 | unsigned long sig = _sig - 1; |
| 39 | if (_NSIG_WORDS == 1) |
| 40 | set->sig[0] |= 1UL << sig; |
| 41 | else |
| 42 | set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW); |
| 43 | } |
| 44 | |
| 45 | static inline void sigdelset(sigset_t *set, int _sig) |
| 46 | { |
| 47 | unsigned long sig = _sig - 1; |
| 48 | if (_NSIG_WORDS == 1) |
| 49 | set->sig[0] &= ~(1UL << sig); |
| 50 | else |
| 51 | set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW)); |
| 52 | } |
| 53 | |
| 54 | static inline int sigismember(sigset_t *set, int _sig) |
| 55 | { |
| 56 | unsigned long sig = _sig - 1; |
| 57 | if (_NSIG_WORDS == 1) |
| 58 | return 1 & (set->sig[0] >> sig); |
| 59 | else |
| 60 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); |
| 61 | } |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #endif /* __HAVE_ARCH_SIG_BITOPS */ |
| 64 | |
George Anzinger | 71fabd5 | 2006-01-08 01:02:48 -0800 | [diff] [blame] | 65 | static inline int sigisemptyset(sigset_t *set) |
| 66 | { |
George Anzinger | 71fabd5 | 2006-01-08 01:02:48 -0800 | [diff] [blame] | 67 | switch (_NSIG_WORDS) { |
| 68 | case 4: |
| 69 | return (set->sig[3] | set->sig[2] | |
| 70 | set->sig[1] | set->sig[0]) == 0; |
| 71 | case 2: |
| 72 | return (set->sig[1] | set->sig[0]) == 0; |
| 73 | case 1: |
| 74 | return set->sig[0] == 0; |
| 75 | default: |
Oleg Nesterov | 1c3bea0 | 2014-10-13 15:53:33 -0700 | [diff] [blame] | 76 | BUILD_BUG(); |
George Anzinger | 71fabd5 | 2006-01-08 01:02:48 -0800 | [diff] [blame] | 77 | return 0; |
| 78 | } |
| 79 | } |
| 80 | |
Waiman Long | c7be96a | 2016-12-14 15:04:10 -0800 | [diff] [blame] | 81 | static inline int sigequalsets(const sigset_t *set1, const sigset_t *set2) |
| 82 | { |
| 83 | switch (_NSIG_WORDS) { |
| 84 | case 4: |
| 85 | return (set1->sig[3] == set2->sig[3]) && |
| 86 | (set1->sig[2] == set2->sig[2]) && |
| 87 | (set1->sig[1] == set2->sig[1]) && |
| 88 | (set1->sig[0] == set2->sig[0]); |
| 89 | case 2: |
| 90 | return (set1->sig[1] == set2->sig[1]) && |
| 91 | (set1->sig[0] == set2->sig[0]); |
| 92 | case 1: |
| 93 | return set1->sig[0] == set2->sig[0]; |
| 94 | } |
| 95 | return 0; |
| 96 | } |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #define sigmask(sig) (1UL << ((sig) - 1)) |
| 99 | |
| 100 | #ifndef __HAVE_ARCH_SIG_SETOPS |
| 101 | #include <linux/string.h> |
| 102 | |
| 103 | #define _SIG_SET_BINOP(name, op) \ |
| 104 | static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \ |
| 105 | { \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \ |
| 107 | \ |
| 108 | switch (_NSIG_WORDS) { \ |
Oleg Nesterov | 1c3bea0 | 2014-10-13 15:53:33 -0700 | [diff] [blame] | 109 | case 4: \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | a3 = a->sig[3]; a2 = a->sig[2]; \ |
| 111 | b3 = b->sig[3]; b2 = b->sig[2]; \ |
| 112 | r->sig[3] = op(a3, b3); \ |
| 113 | r->sig[2] = op(a2, b2); \ |
Oleg Nesterov | 1c3bea0 | 2014-10-13 15:53:33 -0700 | [diff] [blame] | 114 | case 2: \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | a1 = a->sig[1]; b1 = b->sig[1]; \ |
| 116 | r->sig[1] = op(a1, b1); \ |
Oleg Nesterov | 1c3bea0 | 2014-10-13 15:53:33 -0700 | [diff] [blame] | 117 | case 1: \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | a0 = a->sig[0]; b0 = b->sig[0]; \ |
| 119 | r->sig[0] = op(a0, b0); \ |
| 120 | break; \ |
Oleg Nesterov | 1c3bea0 | 2014-10-13 15:53:33 -0700 | [diff] [blame] | 121 | default: \ |
| 122 | BUILD_BUG(); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | } \ |
| 124 | } |
| 125 | |
| 126 | #define _sig_or(x,y) ((x) | (y)) |
| 127 | _SIG_SET_BINOP(sigorsets, _sig_or) |
| 128 | |
| 129 | #define _sig_and(x,y) ((x) & (y)) |
| 130 | _SIG_SET_BINOP(sigandsets, _sig_and) |
| 131 | |
Oleg Nesterov | 702a507 | 2011-04-27 22:01:27 +0200 | [diff] [blame] | 132 | #define _sig_andn(x,y) ((x) & ~(y)) |
| 133 | _SIG_SET_BINOP(sigandnsets, _sig_andn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
| 135 | #undef _SIG_SET_BINOP |
| 136 | #undef _sig_or |
| 137 | #undef _sig_and |
Oleg Nesterov | 702a507 | 2011-04-27 22:01:27 +0200 | [diff] [blame] | 138 | #undef _sig_andn |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
| 140 | #define _SIG_SET_OP(name, op) \ |
| 141 | static inline void name(sigset_t *set) \ |
| 142 | { \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | switch (_NSIG_WORDS) { \ |
Oleg Nesterov | 1c3bea0 | 2014-10-13 15:53:33 -0700 | [diff] [blame] | 144 | case 4: set->sig[3] = op(set->sig[3]); \ |
| 145 | set->sig[2] = op(set->sig[2]); \ |
| 146 | case 2: set->sig[1] = op(set->sig[1]); \ |
| 147 | case 1: set->sig[0] = op(set->sig[0]); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | break; \ |
Oleg Nesterov | 1c3bea0 | 2014-10-13 15:53:33 -0700 | [diff] [blame] | 149 | default: \ |
| 150 | BUILD_BUG(); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | } \ |
| 152 | } |
| 153 | |
| 154 | #define _sig_not(x) (~(x)) |
| 155 | _SIG_SET_OP(signotset, _sig_not) |
| 156 | |
| 157 | #undef _SIG_SET_OP |
| 158 | #undef _sig_not |
| 159 | |
| 160 | static inline void sigemptyset(sigset_t *set) |
| 161 | { |
| 162 | switch (_NSIG_WORDS) { |
| 163 | default: |
| 164 | memset(set, 0, sizeof(sigset_t)); |
| 165 | break; |
| 166 | case 2: set->sig[1] = 0; |
| 167 | case 1: set->sig[0] = 0; |
| 168 | break; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | static inline void sigfillset(sigset_t *set) |
| 173 | { |
| 174 | switch (_NSIG_WORDS) { |
| 175 | default: |
| 176 | memset(set, -1, sizeof(sigset_t)); |
| 177 | break; |
| 178 | case 2: set->sig[1] = -1; |
| 179 | case 1: set->sig[0] = -1; |
| 180 | break; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | /* Some extensions for manipulating the low 32 signals in particular. */ |
| 185 | |
| 186 | static inline void sigaddsetmask(sigset_t *set, unsigned long mask) |
| 187 | { |
| 188 | set->sig[0] |= mask; |
| 189 | } |
| 190 | |
| 191 | static inline void sigdelsetmask(sigset_t *set, unsigned long mask) |
| 192 | { |
| 193 | set->sig[0] &= ~mask; |
| 194 | } |
| 195 | |
| 196 | static inline int sigtestsetmask(sigset_t *set, unsigned long mask) |
| 197 | { |
| 198 | return (set->sig[0] & mask) != 0; |
| 199 | } |
| 200 | |
| 201 | static inline void siginitset(sigset_t *set, unsigned long mask) |
| 202 | { |
| 203 | set->sig[0] = mask; |
| 204 | switch (_NSIG_WORDS) { |
| 205 | default: |
| 206 | memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1)); |
| 207 | break; |
| 208 | case 2: set->sig[1] = 0; |
| 209 | case 1: ; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | static inline void siginitsetinv(sigset_t *set, unsigned long mask) |
| 214 | { |
| 215 | set->sig[0] = ~mask; |
| 216 | switch (_NSIG_WORDS) { |
| 217 | default: |
| 218 | memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1)); |
| 219 | break; |
| 220 | case 2: set->sig[1] = -1; |
| 221 | case 1: ; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | #endif /* __HAVE_ARCH_SIG_SETOPS */ |
| 226 | |
| 227 | static inline void init_sigpending(struct sigpending *sig) |
| 228 | { |
| 229 | sigemptyset(&sig->signal); |
| 230 | INIT_LIST_HEAD(&sig->list); |
| 231 | } |
| 232 | |
Oleg Nesterov | 6a14c5c | 2006-03-28 16:11:18 -0800 | [diff] [blame] | 233 | extern void flush_sigqueue(struct sigpending *queue); |
| 234 | |
Jesper Juhl | e5bdd88 | 2005-05-01 08:59:13 -0700 | [diff] [blame] | 235 | /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */ |
| 236 | static inline int valid_signal(unsigned long sig) |
| 237 | { |
| 238 | return sig <= _NSIG ? 1 : 0; |
| 239 | } |
| 240 | |
Oleg Nesterov | b2b07e4 | 2011-05-18 15:08:03 +0200 | [diff] [blame] | 241 | struct timespec; |
| 242 | struct pt_regs; |
| 243 | |
Davide Libenzi | fba2afa | 2007-05-10 22:23:13 -0700 | [diff] [blame] | 244 | extern int next_signal(struct sigpending *pending, sigset_t *mask); |
Oleg Nesterov | 4a30deb | 2009-09-23 15:57:00 -0700 | [diff] [blame] | 245 | extern int do_send_sig_info(int sig, struct siginfo *info, |
| 246 | struct task_struct *p, bool group); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p); |
| 248 | extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *); |
Oleg Nesterov | 943df14 | 2011-04-27 21:44:14 +0200 | [diff] [blame] | 249 | extern int do_sigtimedwait(const sigset_t *, siginfo_t *, |
| 250 | const struct timespec *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | extern int sigprocmask(int, sigset_t *, sigset_t *); |
Al Viro | 77097ae | 2012-04-27 13:58:59 -0400 | [diff] [blame] | 252 | extern void set_current_blocked(sigset_t *); |
| 253 | extern void __set_current_blocked(const sigset_t *); |
Masoud Asgharifard Sharbiani | abd4f75 | 2007-07-22 11:12:28 +0200 | [diff] [blame] | 254 | extern int show_unhandled_signals; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
Richard Weinberger | 828b1f6 | 2013-10-07 15:26:57 +0200 | [diff] [blame] | 256 | extern int get_signal(struct ksignal *ksig); |
Al Viro | 2ce5da1 | 2012-11-07 15:11:25 -0500 | [diff] [blame] | 257 | extern void signal_setup_done(int failed, struct ksignal *ksig, int stepping); |
Oleg Nesterov | d12619b | 2008-02-08 04:19:12 -0800 | [diff] [blame] | 258 | extern void exit_signals(struct task_struct *tsk); |
Oleg Nesterov | b4e7426 | 2014-06-06 14:37:00 -0700 | [diff] [blame] | 259 | extern void kernel_sigaction(int, __sighandler_t); |
| 260 | |
| 261 | static inline void allow_signal(int sig) |
| 262 | { |
| 263 | /* |
| 264 | * Kernel threads handle their own signals. Let the signal code |
| 265 | * know it'll be handled, so that they don't get converted to |
| 266 | * SIGKILL or just silently dropped. |
| 267 | */ |
| 268 | kernel_sigaction(sig, (__force __sighandler_t)2); |
| 269 | } |
| 270 | |
| 271 | static inline void disallow_signal(int sig) |
| 272 | { |
| 273 | kernel_sigaction(sig, SIG_IGN); |
| 274 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
Christoph Lameter | 298ec1e | 2006-12-06 20:32:47 -0800 | [diff] [blame] | 276 | extern struct kmem_cache *sighand_cachep; |
| 277 | |
Masoud Asgharifard Sharbiani | abd4f75 | 2007-07-22 11:12:28 +0200 | [diff] [blame] | 278 | int unhandled_signal(struct task_struct *tsk, int sig); |
| 279 | |
Roland McGrath | 55c0d1f | 2007-05-09 02:33:37 -0700 | [diff] [blame] | 280 | /* |
| 281 | * In POSIX a signal is sent either to a specific thread (Linux task) |
| 282 | * or to the process as a whole (Linux thread group). How the signal |
| 283 | * is sent determines whether it's to one thread or the whole group, |
| 284 | * which determines which signal mask(s) are involved in blocking it |
| 285 | * from being delivered until later. When the signal is delivered, |
| 286 | * either it's caught or ignored by a user handler or it has a default |
| 287 | * effect that applies to the whole thread group (POSIX process). |
| 288 | * |
| 289 | * The possible effects an unblocked signal set to SIG_DFL can have are: |
| 290 | * ignore - Nothing Happens |
| 291 | * terminate - kill the process, i.e. all threads in the group, |
| 292 | * similar to exit_group. The group leader (only) reports |
| 293 | * WIFSIGNALED status to its parent. |
| 294 | * coredump - write a core dump file describing all threads using |
| 295 | * the same mm and then kill all those threads |
| 296 | * stop - stop all the threads in the group, i.e. TASK_STOPPED state |
| 297 | * |
| 298 | * SIGKILL and SIGSTOP cannot be caught, blocked, or ignored. |
| 299 | * Other signals when not blocked and set to SIG_DFL behaves as follows. |
| 300 | * The job control signals also have other special effects. |
| 301 | * |
| 302 | * +--------------------+------------------+ |
| 303 | * | POSIX signal | default action | |
| 304 | * +--------------------+------------------+ |
| 305 | * | SIGHUP | terminate | |
| 306 | * | SIGINT | terminate | |
| 307 | * | SIGQUIT | coredump | |
| 308 | * | SIGILL | coredump | |
| 309 | * | SIGTRAP | coredump | |
| 310 | * | SIGABRT/SIGIOT | coredump | |
| 311 | * | SIGBUS | coredump | |
| 312 | * | SIGFPE | coredump | |
| 313 | * | SIGKILL | terminate(+) | |
| 314 | * | SIGUSR1 | terminate | |
| 315 | * | SIGSEGV | coredump | |
| 316 | * | SIGUSR2 | terminate | |
| 317 | * | SIGPIPE | terminate | |
| 318 | * | SIGALRM | terminate | |
| 319 | * | SIGTERM | terminate | |
| 320 | * | SIGCHLD | ignore | |
| 321 | * | SIGCONT | ignore(*) | |
| 322 | * | SIGSTOP | stop(*)(+) | |
| 323 | * | SIGTSTP | stop(*) | |
| 324 | * | SIGTTIN | stop(*) | |
| 325 | * | SIGTTOU | stop(*) | |
| 326 | * | SIGURG | ignore | |
| 327 | * | SIGXCPU | coredump | |
| 328 | * | SIGXFSZ | coredump | |
| 329 | * | SIGVTALRM | terminate | |
| 330 | * | SIGPROF | terminate | |
| 331 | * | SIGPOLL/SIGIO | terminate | |
| 332 | * | SIGSYS/SIGUNUSED | coredump | |
| 333 | * | SIGSTKFLT | terminate | |
| 334 | * | SIGWINCH | ignore | |
| 335 | * | SIGPWR | terminate | |
| 336 | * | SIGRTMIN-SIGRTMAX | terminate | |
| 337 | * +--------------------+------------------+ |
| 338 | * | non-POSIX signal | default action | |
| 339 | * +--------------------+------------------+ |
| 340 | * | SIGEMT | coredump | |
| 341 | * +--------------------+------------------+ |
| 342 | * |
| 343 | * (+) For SIGKILL and SIGSTOP the action is "always", not just "default". |
| 344 | * (*) Special job control effects: |
| 345 | * When SIGCONT is sent, it resumes the process (all threads in the group) |
| 346 | * from TASK_STOPPED state and also clears any pending/queued stop signals |
| 347 | * (any of those marked with "stop(*)"). This happens regardless of blocking, |
| 348 | * catching, or ignoring SIGCONT. When any stop signal is sent, it clears |
| 349 | * any pending/queued SIGCONT signals; this happens regardless of blocking, |
| 350 | * catching, or ignored the stop signal, though (except for SIGSTOP) the |
| 351 | * default action of stopping the process may happen later or never. |
| 352 | */ |
| 353 | |
| 354 | #ifdef SIGEMT |
| 355 | #define SIGEMT_MASK rt_sigmask(SIGEMT) |
| 356 | #else |
| 357 | #define SIGEMT_MASK 0 |
| 358 | #endif |
| 359 | |
| 360 | #if SIGRTMIN > BITS_PER_LONG |
| 361 | #define rt_sigmask(sig) (1ULL << ((sig)-1)) |
| 362 | #else |
| 363 | #define rt_sigmask(sig) sigmask(sig) |
| 364 | #endif |
Oleg Nesterov | 5c8ccef | 2016-05-23 16:24:02 -0700 | [diff] [blame] | 365 | |
| 366 | #define siginmask(sig, mask) \ |
| 367 | ((sig) < SIGRTMIN && (rt_sigmask(sig) & (mask))) |
Roland McGrath | 55c0d1f | 2007-05-09 02:33:37 -0700 | [diff] [blame] | 368 | |
| 369 | #define SIG_KERNEL_ONLY_MASK (\ |
| 370 | rt_sigmask(SIGKILL) | rt_sigmask(SIGSTOP)) |
| 371 | |
| 372 | #define SIG_KERNEL_STOP_MASK (\ |
| 373 | rt_sigmask(SIGSTOP) | rt_sigmask(SIGTSTP) | \ |
| 374 | rt_sigmask(SIGTTIN) | rt_sigmask(SIGTTOU) ) |
| 375 | |
| 376 | #define SIG_KERNEL_COREDUMP_MASK (\ |
| 377 | rt_sigmask(SIGQUIT) | rt_sigmask(SIGILL) | \ |
| 378 | rt_sigmask(SIGTRAP) | rt_sigmask(SIGABRT) | \ |
| 379 | rt_sigmask(SIGFPE) | rt_sigmask(SIGSEGV) | \ |
| 380 | rt_sigmask(SIGBUS) | rt_sigmask(SIGSYS) | \ |
| 381 | rt_sigmask(SIGXCPU) | rt_sigmask(SIGXFSZ) | \ |
| 382 | SIGEMT_MASK ) |
| 383 | |
| 384 | #define SIG_KERNEL_IGNORE_MASK (\ |
| 385 | rt_sigmask(SIGCONT) | rt_sigmask(SIGCHLD) | \ |
| 386 | rt_sigmask(SIGWINCH) | rt_sigmask(SIGURG) ) |
| 387 | |
Oleg Nesterov | 5c8ccef | 2016-05-23 16:24:02 -0700 | [diff] [blame] | 388 | #define sig_kernel_only(sig) siginmask(sig, SIG_KERNEL_ONLY_MASK) |
| 389 | #define sig_kernel_coredump(sig) siginmask(sig, SIG_KERNEL_COREDUMP_MASK) |
| 390 | #define sig_kernel_ignore(sig) siginmask(sig, SIG_KERNEL_IGNORE_MASK) |
| 391 | #define sig_kernel_stop(sig) siginmask(sig, SIG_KERNEL_STOP_MASK) |
Roland McGrath | 55c0d1f | 2007-05-09 02:33:37 -0700 | [diff] [blame] | 392 | |
Roland McGrath | 55c0d1f | 2007-05-09 02:33:37 -0700 | [diff] [blame] | 393 | #define sig_fatal(t, signr) \ |
| 394 | (!siginmask(signr, SIG_KERNEL_IGNORE_MASK|SIG_KERNEL_STOP_MASK) && \ |
| 395 | (t)->sighand->action[(signr)-1].sa.sa_handler == SIG_DFL) |
| 396 | |
Adrian Bunk | a1c9eea | 2008-02-06 01:36:44 -0800 | [diff] [blame] | 397 | void signals_init(void); |
| 398 | |
Al Viro | 5c49574 | 2012-11-18 15:29:16 -0500 | [diff] [blame] | 399 | int restore_altstack(const stack_t __user *); |
Al Viro | c40702c | 2012-11-20 14:24:26 -0500 | [diff] [blame] | 400 | int __save_altstack(stack_t __user *, unsigned long); |
Al Viro | 5c49574 | 2012-11-18 15:29:16 -0500 | [diff] [blame] | 401 | |
Al Viro | bd1c149a | 2013-09-01 20:35:01 +0100 | [diff] [blame] | 402 | #define save_altstack_ex(uss, sp) do { \ |
| 403 | stack_t __user *__uss = uss; \ |
| 404 | struct task_struct *t = current; \ |
| 405 | put_user_ex((void __user *)t->sas_ss_sp, &__uss->ss_sp); \ |
Stas Sergeev | 2a74213 | 2016-04-14 23:20:04 +0300 | [diff] [blame] | 406 | put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \ |
Al Viro | bd1c149a | 2013-09-01 20:35:01 +0100 | [diff] [blame] | 407 | put_user_ex(t->sas_ss_size, &__uss->ss_size); \ |
Stas Sergeev | 2a74213 | 2016-04-14 23:20:04 +0300 | [diff] [blame] | 408 | if (t->sas_ss_flags & SS_AUTODISARM) \ |
| 409 | sas_ss_reset(t); \ |
Al Viro | bd1c149a | 2013-09-01 20:35:01 +0100 | [diff] [blame] | 410 | } while (0); |
| 411 | |
David Howells | 34db8aa | 2013-04-12 02:29:19 +0100 | [diff] [blame] | 412 | #ifdef CONFIG_PROC_FS |
| 413 | struct seq_file; |
| 414 | extern void render_sigset_t(struct seq_file *, const char *, sigset_t *); |
| 415 | #endif |
| 416 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | #endif /* _LINUX_SIGNAL_H */ |