From: Gerd Knorr <kraxel@bytesex.org>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [RFC/PATCH] fix sigwait + ptrace with NPTL
Date: Wed, 1 Dec 2004 14:13:41 +0100 [thread overview]
Message-ID: <20041201131341.GA20530@bytesex> (raw)
Hi,
When using NPTL glibc implements sigwait() using the rt_sigtimedwait
syscall. The kernel doesn't notify the ptracing process for any signals
delivered via rt_sigtimedwait(), so gdb+strace will not see them.
Below is a patch which fixes that for most archs, it doesn't work
through for those where ptrace_signal_deliver() isn't a noop (i.e.
sparc + sparc64). I suspect to get these fixed as well we'll need
a arch-specific rt_sigtimedwait() ...
Gerd
Index: linux-2.6.10-rc2/kernel/signal.c
===================================================================
--- linux-2.6.10-rc2.orig/kernel/signal.c 2004-11-17 18:40:00.000000000 +0100
+++ linux-2.6.10-rc2/kernel/signal.c 2004-12-01 13:53:35.000000000 +0100
@@ -2163,6 +2163,7 @@ sys_rt_sigtimedwait(const sigset_t __use
}
spin_lock_irq(¤t->sighand->siglock);
+try_again:
sig = dequeue_signal(current, &these, &info);
if (!sig) {
timeout = MAX_SCHEDULE_TIMEOUT;
@@ -2189,6 +2190,40 @@ sys_rt_sigtimedwait(const sigset_t __use
recalc_sigpending();
}
}
+ if (sig && (current->ptrace & PT_PTRACED) && sig != SIGKILL) {
+#if 0 /* FIXME: some archs (sparc) need this ... */
+ ptrace_signal_deliver(regs, cookie);
+#endif
+
+ /* Let the debugger run. */
+ ptrace_stop(sig, &info);
+
+ /* We're back. Did the debugger cancel the sig? */
+ sig = current->exit_code;
+ if (sig == 0)
+ goto try_again;
+
+ current->exit_code = 0;
+
+ /* Update the siginfo structure if the signal has
+ changed. If the debugger wanted something
+ specific in the siginfo structure then it should
+ have updated *info via PTRACE_SETSIGINFO. */
+ if (sig != info.si_signo) {
+ info.si_signo = sig;
+ 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 not in the set we are looking for,
+ requeue it. */
+ if (sigismember(&these, sig)) {
+ specific_send_sig_info(sig, &info, current);
+ goto try_again;
+ }
+ }
spin_unlock_irq(¤t->sighand->siglock);
if (sig) {
reply other threads:[~2004-12-01 13:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041201131341.GA20530@bytesex \
--to=kraxel@bytesex.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.