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