Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jul 2011 19:24:27 +0900 (JST)
From:      AIDA Shinra <shinra@j10n.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/159226: [PATCH] Libedit does not always restore its signal handler
Message-ID:  <20110727102427.DCE9D119C0C@sodans.usata.org>
Resent-Message-ID: <201107271030.p6RAU9B3043118@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help


>Number:         159226
>Category:       bin
>Synopsis:       [PATCH] Libedit does not always restore its signal handler
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 27 10:30:08 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     AIDA Shinra
>Release:        FreeBSD 7.3-RELEASE-p6 i386
>Organization:
>Environment:
System: FreeBSD sodans.usata.org 7.3-RELEASE-p6 FreeBSD 7.3-RELEASE-p6 #1: Mon Jun 27 01:58:42 JST 2011 wm3@sodans.usata.org:/usr/obj/usr/src/sys/KERNEL_SODANS i386


	
>Description:
If a program gets the same signal twice in a single call to el_gets(), editline's internal signal handler is not used to the second one.

>How-To-Repeat:
I found this bug when testing CURRENT's BSD bc.

You can also reproduce the problem by inserting "printf" or "write" to libedit's sig_handler() and run ftp(1).

>Fix:

	Apply the attached patch.

--- libedit-multisignal.diff begins here ---
--- /usr/src/lib/libedit/sig.c	2010-02-10 09:26:20.000000000 +0900
+++ sig.c	2011-07-17 13:31:47.000000000 +0900
@@ -94,9 +94,18 @@
 		if (signo == sighdl[i])
 			break;
 
-	(void) signal(signo, sel->el_signal[i]);
+	if (sel->el_signal[i] != SIG_IGN && signo != SIGCONT) {
+		/* Deliver the signal to my original handler */
+		(void) signal(signo, sel->el_signal[i]);
+		(void) kill(getpid(), signo);
+		(void) sigfillset(&nset);
+		(void) sigdelset(&nset, signo);
+		(void) sigdelset(&nset, SIGCONT);
+		/* delever and maybe stop here */
+		(void) sigsuspend(&nset);
+		(void) signal(signo, sig_handler);
+	}
 	(void) sigprocmask(SIG_SETMASK, &oset, NULL);
-	(void) kill(0, signo);
 }
 
 
--- libedit-multisignal.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110727102427.DCE9D119C0C>