summaryrefslogtreecommitdiffstats
path: root/bin/sh/trap.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1997-11-05 23:33:58 +0000
committerache <ache@FreeBSD.org>1997-11-05 23:33:58 +0000
commit01ee8c1bbd572a2ffb261644cf14d996132f0e26 (patch)
tree4bf75822673f433672c5081f85ae88b735f12def /bin/sh/trap.c
parente0049830ed0b4fdadbd11c56d8c80e4c5bb0b71d (diff)
downloadFreeBSD-src-01ee8c1bbd572a2ffb261644cf14d996132f0e26.zip
FreeBSD-src-01ee8c1bbd572a2ffb261644cf14d996132f0e26.tar.gz
1) Fix longstanding bug:
trap 'echo xxx' 1 2 3 15 read x is not interrupted by ^C (due to restartable read syscall) and must be interrupted per POSIX Worse case: read -t 5 x hangs forever after ^C pressed (supposed to timeout after 5 secs) Fixed by adding siginterrupt(signo, 1) after catch handler installed 2) Do not reinstall sighandler immediately after it is called, BSD do it for us
Diffstat (limited to 'bin/sh/trap.c')
-rw-r--r--bin/sh/trap.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/bin/sh/trap.c b/bin/sh/trap.c
index f227f02..809f1b6 100644
--- a/bin/sh/trap.c
+++ b/bin/sh/trap.c
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: trap.c,v 1.8 1997/02/22 13:58:46 peter Exp $
*/
#ifndef lint
@@ -212,6 +212,7 @@ setsignal(signo)
int action;
sig_t sigact = SIG_DFL;
char *t;
+ long sig;
if ((t = trap[signo]) == NULL)
action = S_DFL;
@@ -280,7 +281,12 @@ setsignal(signo)
case S_IGN: sigact = SIG_IGN; break;
}
*t = action;
- return (long)signal(signo, sigact);
+ sig = (long)signal(signo, sigact);
+#ifdef BSD
+ if (sig != -1 && action == S_CATCH)
+ sig = siginterrupt(signo, 1);
+#endif
+ return sig;
}
@@ -339,8 +345,9 @@ void
onsig(signo)
int signo;
{
-
+#ifndef BSD
signal(signo, onsig);
+#endif
if (signo == SIGINT && trap[SIGINT] == NULL) {
onint();
return;
OpenPOWER on IntegriCloud