From bafd537ec706dd15a618bcece8711ad46dabbba4 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 25 May 2017 13:02:15 +0200 Subject: [PATCH] suspension: do not write anything to the screen for a lone SIGCONT That is: leave the terminal alone when stdin hasn't been reconnected, because without it the user cannot do anything, and seeing the file contents displayed when in fact the shell is active, is confusing. Use a second call to endwin() to wait for stdin getting reconnected. --- src/nano.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/nano.c b/src/nano.c index 4fe35081..3bdff94e 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1205,10 +1205,6 @@ void signal_init(void) act.sa_handler = do_suspend; sigaction(SIGTSTP, &act, NULL); #endif -#ifdef SIGCONT - act.sa_handler = do_continue; - sigaction(SIGCONT, &act, NULL); -#endif } else { #ifdef SIGTSTP act.sa_handler = SIG_IGN; @@ -1245,22 +1241,10 @@ RETSIGTYPE do_suspend(int signal) /* Do what mutt does: send ourselves a SIGSTOP. */ kill(0, SIGSTOP); #endif -} -/* The version of above function that is bound to a key. */ -void do_suspend_void(void) -{ - if (ISSET(SUSPEND)) - do_suspend(0); - else { - statusbar(_("Suspension is not enabled")); - beep(); - } -} + /* Wait for the keyboard to get connected again. */ + endwin(); -/* Handler for SIGCONT (continue after suspend). */ -RETSIGTYPE do_continue(int signal) -{ #ifdef ENABLE_MOUSE if (ISSET(USE_MOUSE)) enable_mouse_support(); @@ -1277,6 +1261,23 @@ RETSIGTYPE do_continue(int signal) #endif } +/* The version of above function that is bound to a key. */ +void do_suspend_void(void) +{ + if (ISSET(SUSPEND)) + do_suspend(0); + else { + statusbar(_("Suspension is not enabled")); + beep(); + } +} + +/* Handler for SIGCONT (continue after suspend). */ +RETSIGTYPE do_continue(int signal) +{ + /* Do nothing. */ +} + #ifndef NANO_TINY /* Handler for SIGWINCH (window size change). */ RETSIGTYPE handle_sigwinch(int signal) -- 2.12.3