changeset 5010:335da2816bbe

6598201 Fix for 6586967 broke the unreliable signal(3c) interface
author raf
date Fri, 07 Sep 2007 12:16:51 -0700
parents 83b1f17ae06a
children cc3cba45b236
files usr/src/lib/libc/port/threads/sigaction.c
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/libc/port/threads/sigaction.c	Fri Sep 07 12:08:47 2007 -0700
+++ b/usr/src/lib/libc/port/threads/sigaction.c	Fri Sep 07 12:16:51 2007 -0700
@@ -225,11 +225,28 @@
 {
 	extern int __sigresend(int, siginfo_t *, sigset_t *);
 	ulwp_t *self = curthread;
+	siguaction_t *suap = &self->ul_uberdata->siguaction[sig];
 	siginfo_t *sip;
 	int error;
 
 	ASSERT((self->ul_critical | self->ul_sigdefer | self->ul_cursig) == 0);
 
+	/*
+	 * If the signal handler was established with SA_RESETHAND,
+	 * the kernel has reset the handler to SIG_DFL, so we have
+	 * to reestablish the handler now so that it will be entered
+	 * again when we call __sigresend(), below.
+	 */
+	lrw_wrlock(&suap->sig_lock);
+	if (suap->sig_uaction.sa_flags & SA_RESETHAND) {
+		struct sigaction tact = suap->sig_uaction;
+		tact.sa_flags &= ~SA_NODEFER;
+		tact.sa_sigaction = self->ul_uberdata->sigacthandler;
+		tact.sa_mask = maskset;
+		(void) __sigaction(sig, &tact, NULL);
+	}
+	lrw_unlock(&suap->sig_lock);
+
 	if (self->ul_siginfo.si_signo == 0)
 		sip = NULL;
 	else