Skip to content

Commit

Permalink
Allow suspend by keystroke (Ctrl-^ Ctrl-Z)
Browse files Browse the repository at this point in the history
(based on patch by Nickolai Zeldovich)
  • Loading branch information
keithw committed Nov 26, 2012
1 parent 1c2b48a commit 5eafc20
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/frontend/stmclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,23 @@ bool STMClient::process_user_input( int fd )
} else {
return false;
}
} else if ( the_byte == 0x1a ) { /* Suspend sequence is Ctrl-^ Ctrl-Z */
/* Restore terminal and terminal-driver state */
swrite( STDOUT_FILENO, Terminal::Emulator::close().c_str() );

if ( tcsetattr( STDIN_FILENO, TCSANOW, &saved_termios ) < 0 ) {
perror( "tcsetattr" );
exit( 1 );
}

/* clear screen */
printf( "\033[H\033[2J" );
printf( "\033[37;44m[mosh is suspended.]\n\033[m" );

fflush( NULL );

/* actually suspend */
raise( SIGTSTP );
} else if ( the_byte == '^' ) {
/* Emulation sequence to type Ctrl-^ is Ctrl-^ ^ */
network->get_current_state().push_back( Parser::UserByte( 0x1E ) );
Expand Down

0 comments on commit 5eafc20

Please sign in to comment.