* better
[mascara-docs.git] / i386 / linux-2.3.21 / arch / alpha / kernel / signal.c
blobcd8f6e0adb10241448ae4b78b2b04bd9daadd712
1 /*
2 * linux/arch/alpha/kernel/signal.c
4 * Copyright (C) 1995 Linus Torvalds
6 * 1997-11-02 Modified for POSIX.1b signals by Richard Henderson
7 */
9 #include <linux/sched.h>
10 #include <linux/kernel.h>
11 #include <linux/signal.h>
12 #include <linux/errno.h>
13 #include <linux/wait.h>
14 #include <linux/ptrace.h>
15 #include <linux/unistd.h>
16 #include <linux/mm.h>
17 #include <linux/smp.h>
18 #include <linux/smp_lock.h>
19 #include <linux/stddef.h>
21 #include <asm/bitops.h>
22 #include <asm/uaccess.h>
23 #include <asm/sigcontext.h>
24 #include <asm/ucontext.h>
26 #include "proto.h"
29 #define DEBUG_SIG 0
31 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
33 asmlinkage int sys_wait4(int, int *, int, struct rusage *);
34 asmlinkage void ret_from_sys_call(void);
35 asmlinkage int do_signal(sigset_t *, struct pt_regs *,
36 struct switch_stack *, unsigned long, unsigned long);
40 * The OSF/1 sigprocmask calling sequence is different from the
41 * C sigprocmask() sequence..
43 * how:
44 * 1 - SIG_BLOCK
45 * 2 - SIG_UNBLOCK
46 * 3 - SIG_SETMASK
48 * We change the range to -1 .. 1 in order to let gcc easily
49 * use the conditional move instructions.
51 * Note that we don't need to acquire the kernel lock for SMP
52 * operation, as all of this is local to this thread.
54 asmlinkage unsigned long
55 osf_sigprocmask(int how, unsigned long newmask, long a2, long a3,
56 long a4, long a5, struct pt_regs regs)
58 unsigned long oldmask = -EINVAL;
60 if ((unsigned long)how-1 <= 2) {
61 long sign = how-2; /* -1 .. 1 */
62 unsigned long block, unblock;
64 newmask &= _BLOCKABLE;
65 spin_lock_irq(&current->sigmask_lock);
66 oldmask = current->blocked.sig[0];
68 unblock = oldmask & ~newmask;
69 block = oldmask | newmask;
70 if (!sign)
71 block = unblock;
72 if (sign <= 0)
73 newmask = block;
74 if (_NSIG_WORDS > 1 && sign > 0)
75 sigemptyset(&current->blocked);
76 current->blocked.sig[0] = newmask;
77 recalc_sigpending(current);
78 spin_unlock_irq(&current->sigmask_lock);
80 (&regs)->r0 = 0; /* special no error return */
82 return oldmask;
85 asmlinkage int
86 osf_sigaction(int sig, const struct osf_sigaction *act,
87 struct osf_sigaction *oact)
89 struct k_sigaction new_ka, old_ka;
90 int ret;
92 if (act) {
93 old_sigset_t mask;
94 if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
95 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
96 __get_user(new_ka.sa.sa_flags, &act->sa_flags))
97 return -EFAULT;
98 __get_user(mask, &act->sa_mask);
99 siginitset(&new_ka.sa.sa_mask, mask);
100 new_ka.ka_restorer = NULL;
103 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
105 if (!ret && oact) {
106 if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
107 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
108 __put_user(old_ka.sa.sa_flags, &oact->sa_flags))
109 return -EFAULT;
110 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
113 return ret;
116 asmlinkage int
117 sys_rt_sigaction(int sig, const struct sigaction *act, struct sigaction *oact,
118 size_t sigsetsize, void *restorer)
120 struct k_sigaction new_ka, old_ka;
121 int ret;
123 /* XXX: Don't preclude handling different sized sigset_t's. */
124 if (sigsetsize != sizeof(sigset_t))
125 return -EINVAL;
127 if (act) {
128 new_ka.ka_restorer = restorer;
129 if (copy_from_user(&new_ka.sa, act, sizeof(*act)))
130 return -EFAULT;
133 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
135 if (!ret && oact) {
136 if (copy_to_user(oact, &old_ka.sa, sizeof(*oact)))
137 return -EFAULT;
140 return ret;
143 asmlinkage int
144 osf_sigpending(old_sigset_t *set)
146 sigset_t pending;
148 spin_lock_irq(&current->sigmask_lock);
149 sigandsets(&pending, &current->blocked, &current->signal);
150 spin_unlock_irq(&current->sigmask_lock);
152 return copy_to_user(set, &pending, sizeof(*set));
156 * Atomically swap in the new signal mask, and wait for a signal.
158 asmlinkage int
159 do_sigsuspend(old_sigset_t mask, struct pt_regs *reg, struct switch_stack *sw)
161 sigset_t oldset;
163 mask &= _BLOCKABLE;
164 spin_lock_irq(&current->sigmask_lock);
165 oldset = current->blocked;
166 siginitset(&current->blocked, mask);
167 recalc_sigpending(current);
168 spin_unlock_irq(&current->sigmask_lock);
170 while (1) {
171 current->state = TASK_INTERRUPTIBLE;
172 schedule();
173 if (do_signal(&oldset, reg, sw, 0, 0))
174 return -EINTR;
178 asmlinkage int
179 do_rt_sigsuspend(sigset_t *uset, size_t sigsetsize,
180 struct pt_regs *reg, struct switch_stack *sw)
182 sigset_t oldset, set;
184 /* XXX: Don't preclude handling different sized sigset_t's. */
185 if (sigsetsize != sizeof(sigset_t))
186 return -EINVAL;
187 if (copy_from_user(&set, uset, sizeof(set)))
188 return -EFAULT;
190 sigdelsetmask(&set, ~_BLOCKABLE);
191 spin_lock_irq(&current->sigmask_lock);
192 oldset = current->blocked;
193 current->blocked = set;
194 recalc_sigpending(current);
195 spin_unlock_irq(&current->sigmask_lock);
197 while (1) {
198 current->state = TASK_INTERRUPTIBLE;
199 schedule();
200 if (do_signal(&oldset, reg, sw, 0, 0))
201 return -EINTR;
205 asmlinkage int
206 sys_sigaltstack(const stack_t *uss, stack_t *uoss)
208 return do_sigaltstack(uss, uoss, rdusp());
212 * Do a signal return; undo the signal stack.
215 struct sigframe
217 struct sigcontext sc;
218 unsigned long extramask[_NSIG_WORDS-1];
219 unsigned int retcode[3];
222 struct rt_sigframe
224 struct siginfo info;
225 struct ucontext uc;
226 unsigned int retcode[3];
229 #define INSN_MOV_R30_R16 0x47fe0410
230 #define INSN_LDI_R0 0x201f0000
231 #define INSN_CALLSYS 0x00000083
233 static long
234 restore_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
235 struct switch_stack *sw)
237 unsigned long usp;
238 long i, err = 0;
240 err |= __get_user(regs->pc, &sc->sc_pc);
241 sw->r26 = (unsigned long) ret_from_sys_call;
243 err |= __get_user(regs->r0, sc->sc_regs+0);
244 err |= __get_user(regs->r1, sc->sc_regs+1);
245 err |= __get_user(regs->r2, sc->sc_regs+2);
246 err |= __get_user(regs->r3, sc->sc_regs+3);
247 err |= __get_user(regs->r4, sc->sc_regs+4);
248 err |= __get_user(regs->r5, sc->sc_regs+5);
249 err |= __get_user(regs->r6, sc->sc_regs+6);
250 err |= __get_user(regs->r7, sc->sc_regs+7);
251 err |= __get_user(regs->r8, sc->sc_regs+8);
252 err |= __get_user(sw->r9, sc->sc_regs+9);
253 err |= __get_user(sw->r10, sc->sc_regs+10);
254 err |= __get_user(sw->r11, sc->sc_regs+11);
255 err |= __get_user(sw->r12, sc->sc_regs+12);
256 err |= __get_user(sw->r13, sc->sc_regs+13);
257 err |= __get_user(sw->r14, sc->sc_regs+14);
258 err |= __get_user(sw->r15, sc->sc_regs+15);
259 err |= __get_user(regs->r16, sc->sc_regs+16);
260 err |= __get_user(regs->r17, sc->sc_regs+17);
261 err |= __get_user(regs->r18, sc->sc_regs+18);
262 err |= __get_user(regs->r19, sc->sc_regs+19);
263 err |= __get_user(regs->r20, sc->sc_regs+20);
264 err |= __get_user(regs->r21, sc->sc_regs+21);
265 err |= __get_user(regs->r22, sc->sc_regs+22);
266 err |= __get_user(regs->r23, sc->sc_regs+23);
267 err |= __get_user(regs->r24, sc->sc_regs+24);
268 err |= __get_user(regs->r25, sc->sc_regs+25);
269 err |= __get_user(regs->r26, sc->sc_regs+26);
270 err |= __get_user(regs->r27, sc->sc_regs+27);
271 err |= __get_user(regs->r28, sc->sc_regs+28);
272 err |= __get_user(regs->gp, sc->sc_regs+29);
273 err |= __get_user(usp, sc->sc_regs+30);
274 wrusp(usp);
276 for (i = 0; i < 31; i++)
277 err |= __get_user(sw->fp[i], sc->sc_fpregs+i);
278 err |= __get_user(sw->fp[31], &sc->sc_fpcr);
280 return err;
283 asmlinkage void
284 do_sigreturn(struct sigframe *frame, struct pt_regs *regs,
285 struct switch_stack *sw)
287 sigset_t set;
289 /* Verify that it's a good sigcontext before using it */
290 if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
291 goto give_sigsegv;
292 if (__get_user(set.sig[0], &frame->sc.sc_mask)
293 || (_NSIG_WORDS > 1
294 && __copy_from_user(&set.sig[1], &frame->extramask,
295 sizeof(frame->extramask))))
296 goto give_sigsegv;
298 sigdelsetmask(&set, ~_BLOCKABLE);
299 spin_lock_irq(&current->sigmask_lock);
300 current->blocked = set;
301 recalc_sigpending(current);
302 spin_unlock_irq(&current->sigmask_lock);
304 if (restore_sigcontext(&frame->sc, regs, sw))
305 goto give_sigsegv;
307 /* Send SIGTRAP if we're single-stepping: */
308 if (ptrace_cancel_bpt (current))
309 send_sig(SIGTRAP, current, 1);
310 return;
312 give_sigsegv:
313 force_sig(SIGSEGV, current);
316 asmlinkage void
317 do_rt_sigreturn(struct rt_sigframe *frame, struct pt_regs *regs,
318 struct switch_stack *sw)
320 sigset_t set;
321 stack_t st;
323 /* Verify that it's a good sigcontext before using it */
324 if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
325 goto give_sigsegv;
326 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
327 goto give_sigsegv;
329 sigdelsetmask(&set, ~_BLOCKABLE);
330 spin_lock_irq(&current->sigmask_lock);
331 current->blocked = set;
332 recalc_sigpending(current);
333 spin_unlock_irq(&current->sigmask_lock);
335 if (restore_sigcontext(&frame->uc.uc_mcontext, regs, sw))
336 goto give_sigsegv;
338 if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
339 goto give_sigsegv;
340 /* It is more difficult to avoid calling this function than to
341 call it and ignore errors. */
342 do_sigaltstack(&st, NULL, rdusp());
344 /* Send SIGTRAP if we're single-stepping: */
345 if (ptrace_cancel_bpt (current))
346 send_sig(SIGTRAP, current, 1);
347 return;
349 give_sigsegv:
350 force_sig(SIGSEGV, current);
355 * Set up a signal frame.
358 static inline void *
359 get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
361 if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! on_sig_stack(sp))
362 sp = current->sas_ss_sp + current->sas_ss_size;
364 return (void *)((sp - frame_size) & -32ul);
367 static long
368 setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
369 struct switch_stack *sw, unsigned long mask, unsigned long sp)
371 long i, err = 0;
373 err |= __put_user(on_sig_stack((unsigned long)sc), &sc->sc_onstack);
374 err |= __put_user(mask, &sc->sc_mask);
375 err |= __put_user(regs->pc, &sc->sc_pc);
376 err |= __put_user(8, &sc->sc_ps);
378 err |= __put_user(regs->r0 , sc->sc_regs+0);
379 err |= __put_user(regs->r1 , sc->sc_regs+1);
380 err |= __put_user(regs->r2 , sc->sc_regs+2);
381 err |= __put_user(regs->r3 , sc->sc_regs+3);
382 err |= __put_user(regs->r4 , sc->sc_regs+4);
383 err |= __put_user(regs->r5 , sc->sc_regs+5);
384 err |= __put_user(regs->r6 , sc->sc_regs+6);
385 err |= __put_user(regs->r7 , sc->sc_regs+7);
386 err |= __put_user(regs->r8 , sc->sc_regs+8);
387 err |= __put_user(sw->r9 , sc->sc_regs+9);
388 err |= __put_user(sw->r10 , sc->sc_regs+10);
389 err |= __put_user(sw->r11 , sc->sc_regs+11);
390 err |= __put_user(sw->r12 , sc->sc_regs+12);
391 err |= __put_user(sw->r13 , sc->sc_regs+13);
392 err |= __put_user(sw->r14 , sc->sc_regs+14);
393 err |= __put_user(sw->r15 , sc->sc_regs+15);
394 err |= __put_user(regs->r16, sc->sc_regs+16);
395 err |= __put_user(regs->r17, sc->sc_regs+17);
396 err |= __put_user(regs->r18, sc->sc_regs+18);
397 err |= __put_user(regs->r19, sc->sc_regs+19);
398 err |= __put_user(regs->r20, sc->sc_regs+20);
399 err |= __put_user(regs->r21, sc->sc_regs+21);
400 err |= __put_user(regs->r22, sc->sc_regs+22);
401 err |= __put_user(regs->r23, sc->sc_regs+23);
402 err |= __put_user(regs->r24, sc->sc_regs+24);
403 err |= __put_user(regs->r25, sc->sc_regs+25);
404 err |= __put_user(regs->r26, sc->sc_regs+26);
405 err |= __put_user(regs->r27, sc->sc_regs+27);
406 err |= __put_user(regs->r28, sc->sc_regs+28);
407 err |= __put_user(regs->gp , sc->sc_regs+29);
408 err |= __put_user(sp, sc->sc_regs+30);
409 err |= __put_user(0, sc->sc_regs+31);
411 for (i = 0; i < 31; i++)
412 err |= __put_user(sw->fp[i], sc->sc_fpregs+i);
413 err |= __put_user(0, sc->sc_fpregs+31);
414 err |= __put_user(sw->fp[31], &sc->sc_fpcr);
416 err |= __put_user(regs->trap_a0, &sc->sc_traparg_a0);
417 err |= __put_user(regs->trap_a1, &sc->sc_traparg_a1);
418 err |= __put_user(regs->trap_a2, &sc->sc_traparg_a2);
420 return err;
423 static void
424 setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
425 struct pt_regs *regs, struct switch_stack * sw)
427 unsigned long oldsp, r26, err = 0;
428 struct sigframe *frame;
430 oldsp = rdusp();
431 frame = get_sigframe(ka, oldsp, sizeof(*frame));
432 if (verify_area(VERIFY_WRITE, frame, sizeof(*frame)))
433 goto give_sigsegv;
435 err |= setup_sigcontext(&frame->sc, regs, sw, set->sig[0], oldsp);
436 if (_NSIG_WORDS > 1) {
437 err |= __copy_to_user(frame->extramask, &set->sig[1],
438 sizeof(frame->extramask));
441 /* Set up to return from userspace. If provided, use a stub
442 already in userspace. */
443 if (ka->ka_restorer) {
444 r26 = (unsigned long) ka->ka_restorer;
445 } else {
446 err |= __put_user(INSN_MOV_R30_R16, frame->retcode+0);
447 err |= __put_user(INSN_LDI_R0+__NR_sigreturn, frame->retcode+1);
448 err |= __put_user(INSN_CALLSYS, frame->retcode+2);
449 imb();
450 r26 = (unsigned long) frame->retcode;
453 /* Check that everything was written properly. */
454 if (err)
455 goto give_sigsegv;
457 /* "Return" to the handler */
458 regs->r26 = r26;
459 regs->r27 = regs->pc = (unsigned long) ka->sa.sa_handler;
460 regs->r16 = sig; /* a0: signal number */
461 regs->r17 = 0; /* a1: exception code */
462 regs->r18 = (unsigned long) &frame->sc; /* a2: sigcontext pointer */
463 wrusp((unsigned long) frame);
465 #if DEBUG_SIG
466 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
467 current->comm, current->pid, frame, regs->pc, regs->r26);
468 #endif
470 return;
472 give_sigsegv:
473 if (sig == SIGSEGV)
474 ka->sa.sa_handler = SIG_DFL;
475 force_sig(SIGSEGV, current);
478 static void
479 setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
480 sigset_t *set, struct pt_regs *regs, struct switch_stack * sw)
482 unsigned long oldsp, r26, err = 0;
483 struct rt_sigframe *frame;
485 oldsp = rdusp();
486 frame = get_sigframe(ka, oldsp, sizeof(*frame));
487 if (verify_area(VERIFY_WRITE, frame, sizeof(*frame)))
488 goto give_sigsegv;
490 err |= __copy_to_user(&frame->info, info, sizeof(siginfo_t));
492 /* Create the ucontext. */
493 err |= __put_user(0, &frame->uc.uc_flags);
494 err |= __put_user(0, &frame->uc.uc_link);
495 err |= __put_user(set->sig[0], &frame->uc.uc_osf_sigmask);
496 err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
497 err |= __put_user(sas_ss_flags(oldsp), &frame->uc.uc_stack.ss_flags);
498 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
499 err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, sw,
500 set->sig[0], oldsp);
501 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
503 /* Set up to return from userspace. If provided, use a stub
504 already in userspace. */
505 if (ka->ka_restorer) {
506 r26 = (unsigned long) ka->ka_restorer;
507 } else {
508 err |= __put_user(INSN_MOV_R30_R16, frame->retcode+0);
509 err |= __put_user(INSN_LDI_R0+__NR_rt_sigreturn,
510 frame->retcode+1);
511 err |= __put_user(INSN_CALLSYS, frame->retcode+2);
512 imb();
513 r26 = (unsigned long) frame->retcode;
516 if (err)
517 goto give_sigsegv;
519 /* "Return" to the handler */
520 regs->r26 = r26;
521 regs->r27 = regs->pc = (unsigned long) ka->sa.sa_handler;
522 regs->r16 = sig; /* a0: signal number */
523 regs->r17 = (unsigned long) &frame->info; /* a1: siginfo pointer */
524 regs->r18 = (unsigned long) &frame->uc; /* a2: ucontext pointer */
525 wrusp((unsigned long) frame);
527 #if DEBUG_SIG
528 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
529 current->comm, current->pid, frame, regs->pc, regs->r26);
530 #endif
532 return;
534 give_sigsegv:
535 if (sig == SIGSEGV)
536 ka->sa.sa_handler = SIG_DFL;
537 force_sig(SIGSEGV, current);
542 * OK, we're invoking a handler.
544 static inline void
545 handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
546 sigset_t *oldset, struct pt_regs * regs, struct switch_stack *sw)
548 if (ka->sa.sa_flags & SA_SIGINFO)
549 setup_rt_frame(sig, ka, info, oldset, regs, sw);
550 else
551 setup_frame(sig, ka, oldset, regs, sw);
553 if (ka->sa.sa_flags & SA_RESETHAND)
554 ka->sa.sa_handler = SIG_DFL;
556 if (!(ka->sa.sa_flags & SA_NODEFER)) {
557 spin_lock_irq(&current->sigmask_lock);
558 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
559 sigaddset(&current->blocked,sig);
560 recalc_sigpending(current);
561 spin_unlock_irq(&current->sigmask_lock);
565 static inline void
566 syscall_restart(unsigned long r0, unsigned long r19,
567 struct pt_regs *regs, struct k_sigaction *ka)
569 switch (regs->r0) {
570 case ERESTARTSYS:
571 if (!(ka->sa.sa_flags & SA_RESTART)) {
572 case ERESTARTNOHAND:
573 regs->r0 = EINTR;
574 break;
576 /* fallthrough */
577 case ERESTARTNOINTR:
578 regs->r0 = r0; /* reset v0 and a3 and replay syscall */
579 regs->r19 = r19;
580 regs->pc -= 4;
581 break;
587 * Note that 'init' is a special process: it doesn't get signals it doesn't
588 * want to handle. Thus you cannot kill init even with a SIGKILL even by
589 * mistake.
591 * Note that we go through the signals twice: once to check the signals that
592 * the kernel can handle, and then we build all the user-level signal handling
593 * stack-frames in one go after that.
595 * "r0" and "r19" are the registers we need to restore for system call
596 * restart. "r0" is also used as an indicator whether we can restart at
597 * all (if we get here from anything but a syscall return, it will be 0)
599 asmlinkage int
600 do_signal(sigset_t *oldset, struct pt_regs * regs, struct switch_stack * sw,
601 unsigned long r0, unsigned long r19)
603 unsigned long single_stepping = ptrace_cancel_bpt(current);
605 if (!oldset)
606 oldset = &current->blocked;
608 while (1) {
609 unsigned long signr;
610 struct k_sigaction *ka;
611 siginfo_t info;
613 spin_lock_irq(&current->sigmask_lock);
614 signr = dequeue_signal(&current->blocked, &info);
615 spin_unlock_irq(&current->sigmask_lock);
617 if (!signr)
618 break;
620 if ((current->flags & PF_PTRACED) && signr != SIGKILL) {
621 /* Let the debugger run. */
622 current->exit_code = signr;
623 current->state = TASK_STOPPED;
624 notify_parent(current, SIGCHLD);
625 schedule();
626 single_stepping |= ptrace_cancel_bpt(current);
628 /* We're back. Did the debugger cancel the sig? */
629 if (!(signr = current->exit_code))
630 continue;
631 current->exit_code = 0;
633 /* The debugger continued. Ignore SIGSTOP. */
634 if (signr == SIGSTOP)
635 continue;
637 /* Update the siginfo structure. Is this good? */
638 if (signr != info.si_signo) {
639 info.si_signo = signr;
640 info.si_errno = 0;
641 info.si_code = SI_USER;
642 info.si_pid = current->p_pptr->pid;
643 info.si_uid = current->p_pptr->uid;
646 /* If the (new) signal is now blocked, requeue it. */
647 if (sigismember(&current->blocked, signr)) {
648 send_sig_info(signr, &info, current);
649 continue;
653 ka = &current->sig->action[signr-1];
654 if (ka->sa.sa_handler == SIG_IGN) {
655 if (signr != SIGCHLD)
656 continue;
657 /* Check for SIGCHLD: it's special. */
658 while (sys_wait4(-1, NULL, WNOHANG, NULL) > 0)
659 /* nothing */;
660 continue;
663 if (ka->sa.sa_handler == SIG_DFL) {
664 int exit_code = signr & 0x7f;
666 /* Init gets no signals it doesn't want. */
667 if (current->pid == 1)
668 continue;
670 switch (signr) {
671 case SIGCONT: case SIGCHLD: case SIGWINCH:
672 continue;
674 case SIGTSTP: case SIGTTIN: case SIGTTOU:
675 if (is_orphaned_pgrp(current->pgrp))
676 continue;
677 /* FALLTHRU */
679 case SIGSTOP:
680 current->state = TASK_STOPPED;
681 current->exit_code = signr;
682 if (!(current->p_pptr->sig->action[SIGCHLD-1]
683 .sa.sa_flags & SA_NOCLDSTOP))
684 notify_parent(current, SIGCHLD);
685 schedule();
686 single_stepping |= ptrace_cancel_bpt(current);
687 continue;
689 case SIGQUIT: case SIGILL: case SIGTRAP:
690 case SIGABRT: case SIGFPE: case SIGSEGV:
691 if (do_coredump(signr, regs))
692 exit_code |= 0x80;
693 /* FALLTHRU */
695 default:
696 lock_kernel();
697 sigaddset(&current->signal, signr);
698 current->flags |= PF_SIGNALED;
699 do_exit(exit_code);
700 /* NOTREACHED */
702 continue;
705 /* Whee! Actually deliver the signal. */
706 if (r0) syscall_restart(r0, r19, regs, ka);
707 handle_signal(signr, ka, &info, oldset, regs, sw);
708 if (single_stepping)
709 ptrace_set_bpt(current); /* re-set bpt */
710 return 1;
713 if (r0 &&
714 (regs->r0 == ERESTARTNOHAND ||
715 regs->r0 == ERESTARTSYS ||
716 regs->r0 == ERESTARTNOINTR)) {
717 regs->r0 = r0; /* reset v0 and a3 and replay syscall */
718 regs->r19 = r19;
719 regs->pc -= 4;
721 if (single_stepping)
722 ptrace_set_bpt(current); /* re-set breakpoint */
724 return 0;