lkml.org 
[lkml]   [2004]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC/PATCH] fix sigwait + ptrace with NPTL
  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(&current->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(&current->sighand->siglock);

if (sig) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.025 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site