* [RFC/PATCH] fix sigwait + ptrace with NPTL
@ 2004-12-01 13:13 Gerd Knorr
0 siblings, 0 replies; only message in thread
From: Gerd Knorr @ 2004-12-01 13:13 UTC (permalink / raw)
To: Linux Kernel Mailing List
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) {
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-12-01 13:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-01 13:13 [RFC/PATCH] fix sigwait + ptrace with NPTL Gerd Knorr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).