diff --git a/src/frontend/stmclient.cc b/src/frontend/stmclient.cc index 07238bc..4b64e14 100644 --- a/src/frontend/stmclient.cc +++ b/src/frontend/stmclient.cc @@ -62,6 +62,21 @@ #include "networktransport.cc" +void STMClient::resume( void ) +{ + /* Restore termios state */ + if ( tcsetattr( STDIN_FILENO, TCSANOW, &raw_termios ) < 0 ) { + perror( "tcsetattr" ); + exit( 1 ); + } + + /* Put terminal in application-cursor-key mode */ + swrite( STDOUT_FILENO, Terminal::Emulator::open().c_str() ); + + /* Flag that outer terminal state is unknown */ + repaint_requested = true; +} + void STMClient::init( void ) { if ( !is_utf8_locale() ) { @@ -146,7 +161,6 @@ void STMClient::main_init( void ) sel.add_signal( SIGINT ); sel.add_signal( SIGHUP ); sel.add_signal( SIGPIPE ); - sel.add_signal( SIGTSTP ); sel.add_signal( SIGCONT ); /* get initial window size */ @@ -376,12 +390,14 @@ void STMClient::main( void ) if ( !process_resize() ) { return; } } + if ( sel.signal( SIGCONT ) ) { + resume(); + } + if ( sel.signal( SIGTERM ) || sel.signal( SIGINT ) || sel.signal( SIGHUP ) - || sel.signal( SIGPIPE ) - || sel.signal( SIGTSTP ) - || sel.signal( SIGCONT ) ) { + || sel.signal( SIGPIPE ) ) { /* shutdown signal */ if ( !network->has_remote_addr() ) { break; diff --git a/src/frontend/stmclient.h b/src/frontend/stmclient.h index d939dcf..0b79991 100644 --- a/src/frontend/stmclient.h +++ b/src/frontend/stmclient.h @@ -74,6 +74,8 @@ private: return network && ( network->get_remote_state_num() == 0 ); } + void resume( void ); /* restore state after SIGCONT */ + public: STMClient( const char *s_ip, int s_port, const char *s_key, const char *predict_mode ) : ip( s_ip ), port( s_port ), key( s_key ),