]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
more: fix SIGSTOP and SIGCONT handling
authorSami Kerola <kerolasa@iki.fi>
Sat, 28 Mar 2020 10:17:46 +0000 (10:17 +0000)
committerSami Kerola <kerolasa@iki.fi>
Mon, 13 Apr 2020 11:14:07 +0000 (12:14 +0100)
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 <kerolasa@iki.fi>
text-utils/more.c

index 4a8abed8087ce7b78427cae6838ae9865f186622..ff3dfe3b4b746a639eb2d3f6abf040d6767ab827 100644 (file)
@@ -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);