From 072ea41682be093fd5fb25e7d6669a65a76144e6 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 21 Apr 2016 18:18:05 -0700 Subject: Fix more to not append an extra newline. More's sigatexit handler needs to distinguish between normal exit and exit due to receipt of a signal. Change tty_sigreset to look at the signal number too, so that pressing 'q' to exit top doesn't cause its exit status to be 128. --- toys/pending/more.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'toys/pending/more.c') diff --git a/toys/pending/more.c b/toys/pending/more.c index 59b5c615..7923ee4e 100644 --- a/toys/pending/more.c +++ b/toys/pending/more.c @@ -25,7 +25,12 @@ GLOBALS( static void signal_handler(int sig) { + // Reset the terminal whether we were signalled or exited normally. tcsetattr(TT.cin_fd, TCSANOW, &TT.inf); + + if (sig == 0) _exit(0); + + // We were actually signalled, so move to a new line and re-raise the signal. xputc('\n'); signal(sig, SIG_DFL); raise(sig); -- cgit v1.2.3