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