diff mbox series

input: Check for int_pending while clearing input

Message ID Y7Z4dM091n25aUQa@gondor.apana.org.au (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series input: Check for int_pending while clearing input | expand

Commit Message

Herbert Xu Jan. 5, 2023, 7:12 a.m. UTC
On Wed, Jan 04, 2023 at 02:59:23PM +0000, Harald van Dijk wrote:
>
> As long as we're talking about things like that, regardless of how it's
> implemented, we could also get another SIGINT during the skipping of the
> rest of the input line.

Actually, that's a good point and we should stop clearing the line
if we detect SIGINT.

---8<---
If we receive SIGINT while clearing a partially read line from
stdin we should bail out instead of continuing.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Thanks,
diff mbox series

Patch

diff --git a/src/input.c b/src/input.c
index 8691617..1c83287 100644
--- a/src/input.c
+++ b/src/input.c
@@ -89,7 +89,8 @@  RESET {
 	popallfiles();
 	basepf.unget = 0;
 	while (basepf.lastc[0] != '\n' &&
-	       basepf.lastc[0] != PEOF)
+	       basepf.lastc[0] != PEOF &&
+	       !int_pending())
 		pgetc();
 }