From: anton Date: Thu, 22 Jun 2017 18:05:31 +0000 (+0000) Subject: Make sure to abort loops when pressing ^C in csh. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=046eeb9033ac396ed1d256b7366ad6224180582f;p=openbsd Make sure to abort loops when pressing ^C in csh. Regression found by deraadt@ --- diff --git a/bin/csh/file.c b/bin/csh/file.c index 867dee4b2f6..68b0c16e218 100644 --- a/bin/csh/file.c +++ b/bin/csh/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.26 2017/06/21 19:36:23 anton Exp $ */ +/* $OpenBSD: file.c,v 1.27 2017/06/22 18:05:31 anton Exp $ */ /* $NetBSD: file.c,v 1.11 1996/11/08 19:34:37 christos Exp $ */ /*- @@ -224,6 +224,11 @@ static int cl_abort(struct cmdline *cl, int c) { cl_visc(cl, c); + + /* Abort while/foreach loop prematurely. */ + if (whyles) + kill(getpid(), SIGINT); + cl_putc(cl, '\n'); cl->len = cl->cursor = 0; cl->flags |= CL_PROMPT; diff --git a/regress/bin/csh/filec.sh b/regress/bin/csh/filec.sh index 3b7dc5bd58a..338a91762b7 100644 --- a/regress/bin/csh/filec.sh +++ b/regress/bin/csh/filec.sh @@ -76,6 +76,7 @@ testseq "\t\0177" " % \b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b" # VINTR: Abort line. testseq "\0003" " % ^C\r\n % " testseq "ab\0003" " % ab^C\r\n % " +testseq "foreach i ()\n\0003a" " % foreach i ()\r\n? ^C\r\r\n % a" # VKILL: Kill line. testseq "\0025" " % "