Module Name: src Committed By: christos Date: Sat Sep 3 19:33:40 UTC 2011
Modified Files: src/sys/kern: kern_sig.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.312 -r1.313 src/sys/kern/kern_sig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_sig.c diff -u src/sys/kern/kern_sig.c:1.312 src/sys/kern/kern_sig.c:1.313 --- src/sys/kern/kern_sig.c:1.312 Wed Aug 31 18:43:19 2011 +++ src/sys/kern/kern_sig.c Sat Sep 3 15:33:40 2011 @@ -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);