From 6dcaaa9ef512c6b8261f2219db2a7cab24c1a65f Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 28 Mar 2020 10:17:46 +0000 Subject: [PATCH] more: fix SIGSTOP and SIGCONT handling When suspending only the more process. Sending signal to process group makes signal destination unnecessarily vague. After the suspend is over SIGCONT is expected, and it needs to ensure output terminal settings are what more needs. Signed-off-by: Sami Kerola --- text-utils/more.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/text-utils/more.c b/text-utils/more.c index 4a8abed808..ff3dfe3b4b 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -1058,8 +1058,12 @@ static void sigtstp_handler(struct more_control *ctl) { reset_tty(ctl); fflush(NULL); - kill(0, SIGSTOP); - /* We're back */ + kill(getpid(), SIGSTOP); +} + +/* Come here when we get a continue signal from the terminal */ +static void sigcont_handler(struct more_control *ctl) +{ set_tty(ctl); } @@ -1296,6 +1300,9 @@ static int more_poll(struct more_control *ctl, int timeout) case SIGTSTP: sigtstp_handler(ctl); break; + case SIGCONT: + sigcont_handler(ctl); + break; case SIGWINCH: sigwinch_handler(ctl); break; @@ -2055,6 +2062,7 @@ int main(int argc, char **argv) sigaddset(&ctl.sigset, SIGINT); sigaddset(&ctl.sigset, SIGQUIT); sigaddset(&ctl.sigset, SIGTSTP); + sigaddset(&ctl.sigset, SIGCONT); sigaddset(&ctl.sigset, SIGWINCH); sigprocmask(SIG_BLOCK, &ctl.sigset, NULL); ctl.sigfd = signalfd(-1, &ctl.sigset, SFD_CLOEXEC); -- 2.47.2