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