From acbb6deec378b6fc0d456a9e25f1628759f51779 Mon Sep 17 00:00:00 2001 From: anton Date: Fri, 3 Nov 2023 19:32:28 +0000 Subject: [PATCH] Check if a signal already has been received before entering a blocking read as opposed of only doing it afterwards. Issue uncovered by the mail regress tests. With claudio@ and ok millert@ --- usr.bin/mail/tty.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/mail/tty.c b/usr.bin/mail/tty.c index 51f7ab7797b..0cc2bae7c0e 100644 --- a/usr.bin/mail/tty.c +++ b/usr.bin/mail/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.23 2023/03/08 04:43:11 guenther Exp $ */ +/* $OpenBSD: tty.c,v 1.24 2023/11/03 19:32:28 anton Exp $ */ /* $NetBSD: tty.c,v 1.7 1997/07/09 05:25:46 mikel Exp $ */ /* @@ -324,7 +324,10 @@ tty_getc(struct tty *t) ssize_t n; unsigned char c; - n = read(t->fdin, &c, 1); + if (ttysignal != 0) + n = -1; + else + n = read(t->fdin, &c, 1); switch (n) { case -1: t->flags |= TTY_ERR; -- 2.20.1