Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern PR/45327: Jared McNeill: ptrace: siginfo doesn't wo...



details:   https://anonhg.NetBSD.org/src/rev/f5a31d37934d
branches:  trunk
changeset: 769221:f5a31d37934d
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Sep 03 19:33:40 2011 +0000

description:
PR/45327: Jared McNeill: ptrace: siginfo doesn't work with traced processes
When saving the signal in p->p_xstat, clear it from the pending mask, but
don't remove it from the siginfo queue, so that next time the debugger
delivers it, the original information is found.
When posting a signal from the debugger l->l_sigpendset is not set, so we
use the process pending signal and add it back to the process pending set.

diffstat:

 sys/kern/kern_sig.c |  20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diffs (55 lines):

diff -r 6556a7ba73a1 -r f5a31d37934d sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Sat Sep 03 19:07:32 2011 +0000
+++ b/sys/kern/kern_sig.c       Sat Sep 03 19:33:40 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.312 2011/08/31 22:43:19 rmind Exp $     */
+/*     $NetBSD: kern_sig.c,v 1.313 2011/09/03 19:33:40 christos Exp $  */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.312 2011/08/31 22:43:19 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.313 2011/09/03 19:33:40 christos Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_compat_sunos.h"
@@ -1850,8 +1850,12 @@
                 */
                if ((p->p_slflag & PSL_TRACED) != 0 &&
                    (p->p_lflag & PL_PPWAIT) == 0 && signo != SIGKILL) {
-                       /* Take the signal. */
-                       (void)sigget(sp, NULL, signo, NULL);
+                       /*
+                        * Take the signal, but don't remove it from the
+                        * siginfo queue, because the debugger can send
+                        * it later.
+                        */
+                       sigdelset(&sp->sp_set, signo);
                        p->p_xstat = signo;
 
                        /* Emulation-specific handling of signal trace */
@@ -1966,6 +1970,7 @@
        sig_t           action;
        sigset_t        *returnmask;
        ksiginfo_t      ksi;
+       sigpend_t       *sp;
 
        l = curlwp;
        p = l->l_proc;
@@ -1993,7 +1998,12 @@
         */
        action = SIGACTION_PS(ps, signo).sa_handler;
        l->l_ru.ru_nsignals++;
-       sigget(l->l_sigpendset, &ksi, signo, NULL);
+       if ((sp = l->l_sigpendset) == NULL) {
+               /* From the debugger */
+               sp = &p->p_sigpend;
+               sigaddset(&sp->sp_set, signo);
+       }
+       sigget(sp, &ksi, signo, NULL);
 
        if (ktrpoint(KTR_PSIG)) {
                mutex_exit(p->p_lock);



Home | Main Index | Thread Index | Old Index