From: Kenn H. <ke...@us...> - 2003-01-12 22:45:05
|
Update of /cvsroot/linux-vax/kernel-2.5/arch/vax/kernel In directory sc8-pr-cvs1:/tmp/cvs-serv28089/arch/vax/kernel Modified Files: signal.c Log Message: 2.5.19 moves some common signal handling code out of arch code and into core kernel Index: signal.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/arch/vax/kernel/signal.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- signal.c 7 Dec 2002 00:14:56 -0000 1.6 +++ signal.c 12 Jan 2003 22:45:02 -0000 1.7 @@ -44,41 +44,6 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs); -int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from) -{ - if (!access_ok (VERIFY_WRITE, to, sizeof(siginfo_t))) - return -EFAULT; - if (from->si_code < 0) - return __copy_to_user(to, from, sizeof(siginfo_t)); - else { - int err; - - /* If you change siginfo_t structure, please be sure - this code is fixed accordingly. - It should never copy any pad contained in the structure - to avoid security leaks, but must copy the generic - 3 ints plus the relevant union member. */ - err = __put_user(from->si_signo, &to->si_signo); - err |= __put_user(from->si_errno, &to->si_errno); - err |= __put_user((short)from->si_code, &to->si_code); - /* First 32bits of unions are always present. */ - err |= __put_user(from->si_pid, &to->si_pid); - switch (from->si_code >> 16) { - case __SI_FAULT >> 16: - break; - case __SI_CHLD >> 16: - err |= __put_user(from->si_utime, &to->si_utime); - err |= __put_user(from->si_stime, &to->si_stime); - err |= __put_user(from->si_status, &to->si_status); - default: - err |= __put_user(from->si_uid, &to->si_uid); - break; - /* case __SI_RT: This is not generated by the kernel as of now. */ - } - return err; - } -} - /* * Atomically swap in the new signal mask, and wait for a signal. */ @@ -590,9 +555,11 @@ */ static inline void -handle_signal(int canrestart, unsigned long sig, struct k_sigaction *ka, - siginfo_t *info, sigset_t *oldset, struct pt_regs * regs) +handle_signal(int canrestart, unsigned long sig, siginfo_t *info, + sigset_t *oldset, struct pt_regs * regs) { + struct k_sigaction *ka = ¤t->sig->action[sig-1]; + /* Are we from a system call? */ if (canrestart) { /* If so, check system call restarting.. */ @@ -648,7 +615,7 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs) { siginfo_t info; - struct k_sigaction *ka; + int signr; int canrestart; /* * We want the common case to go fast, which @@ -668,113 +635,10 @@ oldset = ¤t->blocked; - for (;;) { - unsigned long signr; - - spin_lock_irq(¤t->sigmask_lock); - signr = dequeue_signal(¤t->blocked, &info); - spin_unlock_irq(¤t->sigmask_lock); -#ifdef DEBUG_SIG - printk(" sig %d\n",signr); -#endif - if (!signr) - break; - - if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) { - /* Let the debugger run. */ - current->exit_code = signr; - current->state = TASK_STOPPED; - notify_parent(current, SIGCHLD); - schedule(); - - /* We're back. Did the debugger cancel the sig? */ - if (!(signr = current->exit_code)) - continue; - current->exit_code = 0; - - /* The debugger continued. Ignore SIGSTOP. */ - if (signr == SIGSTOP) - continue; - - /* Update the siginfo structure. Is this good? */ - if (signr != info.si_signo) { - info.si_signo = signr; - info.si_errno = 0; - info.si_code = SI_USER; - info.si_pid = current->parent->pid; - info.si_uid = current->parent->uid; - } - - /* If the (new) signal is now blocked, requeue it. */ - if (sigismember(¤t->blocked, signr)) { - send_sig_info(signr, &info, current); - continue; - } - } - - ka = ¤t->sig->action[signr-1]; - if (ka->sa.sa_handler == SIG_IGN) { - if (signr != SIGCHLD) - continue; -#ifdef DEBUG_SIG - printk("do_signal: waiting for sigchld\n"); -#endif - /* Check for SIGCHLD: it's special. */ - while (sys_wait4(-1, NULL, WNOHANG, NULL) > 0) - /* nothing */; - continue; - } - - if (ka->sa.sa_handler == SIG_DFL) { - int exit_code = signr; -#ifdef DEBUG_SIG - printk("do_signal: invoking default handler for sig %d\n",signr); -#endif - /* Init gets no signals it doesn't want. */ - if (current->pid == 1) - continue; - - switch (signr) { - case SIGCONT: case SIGCHLD: case SIGWINCH: - continue; - - case SIGTSTP: case SIGTTIN: case SIGTTOU: - if (is_orphaned_pgrp(current->pgrp)) - continue; - /* FALLTHRU */ - - case SIGSTOP: - current->state = TASK_STOPPED; - current->exit_code = signr; - if (!(current->parent->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP)) - notify_parent(current, SIGCHLD); - schedule(); - continue; - - case SIGQUIT: case SIGILL: case SIGTRAP: - case SIGABRT: case SIGFPE: case SIGSEGV: - case SIGBUS: case SIGSYS: case SIGXCPU: case SIGXFSZ: - if (do_coredump(signr, regs)) - exit_code |= 0x80; - /* FALLTHRU */ - - default: - //lock_kernel(); - sigaddset(¤t->pending.signal, signr); - recalc_sigpending(); - current->flags |= PF_SIGNALED; -#ifdef DEBUG_SIG - printk("handle_sig: do_exit exit_code=%d\n",exit_code); -#endif - do_exit(exit_code); - /* NOTREACHED */ - } - } -#ifdef DEBUG_SIG - printk("do_signal: handle_signal(canrestart=%d,signr=%d,info=%p,ka->sa.sa_handler=%p)\n",canrestart,signr,info,ka->sa.sa_handler); -#endif + signr = get_signal_to_deliver(&info, regs); + if (signr > 0) { /* Whee! Actually deliver the signal. */ - handle_signal(canrestart, signr, ka, &info, oldset, regs); + handle_signal(canrestart, signr, &info, oldset, regs); return 1; } |