From 22f5d581441edea87ad1666390cde06dfa5f17c1 Mon Sep 17 00:00:00 2001 From: John Hood Date: Sat, 5 Nov 2016 19:40:30 -0400 Subject: [PATCH] Exit gracefully on pty write or ioctl failure. Fixes #821, OS X abnormal exit on client input at mosh-server shutdown. On OpenIndiana, TIOCG[GS]WINSZ also fail in this situation. --- src/frontend/mosh-server.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 1022a34..effe6ef 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -700,13 +700,13 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection & struct winsize window_size; if ( ioctl( host_fd, TIOCGWINSZ, &window_size ) < 0 ) { perror( "ioctl TIOCGWINSZ" ); - return; + network.start_shutdown(); } window_size.ws_col = res->width; window_size.ws_row = res->height; if ( ioctl( host_fd, TIOCSWINSZ, &window_size ) < 0 ) { perror( "ioctl TIOCSWINSZ" ); - return; + network.start_shutdown(); } } terminal_to_host += terminal.act( action ); @@ -782,7 +782,7 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection & /* write user input and terminal writeback to the host */ if ( swrite( host_fd, terminal_to_host.c_str(), terminal_to_host.length() ) < 0 ) { - break; + network.start_shutdown(); } bool idle_shutdown = false;