Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

mosh-server: Allow startup without PTY

  • Loading branch information...
commit 45bba44c83d0b5f6da32327bbcbd2a42d22adbb2 1 parent c6bf3a2
Keith Winstein authored
Showing with 25 additions and 18 deletions.
  1. +25 −18 src/frontend/mosh-server.cc
43 src/frontend/mosh-server.cc
View
@@ -334,9 +334,13 @@ int run_server( const char *desired_ip, const char *desired_port,
/* get initial window size */
struct winsize window_size;
if ( ioctl( STDIN_FILENO, TIOCGWINSZ, &window_size ) < 0 ) {
- perror( "ioctl TIOCGWINSZ" );
- fprintf( stderr, "If running with ssh, please use ssh -t to provide a PTY.\n" );
- exit( 1 );
+ fprintf( stderr, "Server started without pseudo-terminal. Opening 80x24 terminal.\n" );
+
+ /* Fill in sensible defaults. */
+ /* They will be overwritten by client on first connection. */
+ memset( &window_size, 0, sizeof( window_size ) );
+ window_size.ws_col = 80;
+ window_size.ws_row = 24;
}
/* open parser and terminal */
@@ -361,13 +365,6 @@ int run_server( const char *desired_ip, const char *desired_port,
fatal_assert( 0 == sigaction( SIGHUP, &sa, NULL ) );
fatal_assert( 0 == sigaction( SIGPIPE, &sa, NULL ) );
- struct termios child_termios;
-
- /* Get terminal configuration */
- if ( tcgetattr( STDIN_FILENO, &child_termios ) < 0 ) {
- perror( "tcgetattr" );
- exit( 1 );
- }
/* detach from terminal */
pid_t the_pid = fork();
@@ -385,13 +382,7 @@ int run_server( const char *desired_ip, const char *desired_port,
int master;
-#ifdef HAVE_IUTF8
- if ( !(child_termios.c_iflag & IUTF8) ) {
- /* SSH should also convey IUTF8 across connection. */
- // fprintf( stderr, "Warning: Locale is UTF-8 but termios IUTF8 flag not set. Setting IUTF8 flag.\n" );
- child_termios.c_iflag |= IUTF8;
- }
-#else
+#ifndef HAVE_IUTF8
fprintf( stderr, "\nWarning: termios IUTF8 flag not defined.\nCharacter-erase of multibyte character sequence\nprobably does not work properly on this platform.\n" );
#endif /* HAVE_IUTF8 */
@@ -423,7 +414,7 @@ int run_server( const char *desired_ip, const char *desired_port,
snprintf( utmp_entry, 64, "mosh [%d]", getpid() );
/* Fork child process */
- pid_t child = forkpty( &master, NULL, &child_termios, &window_size );
+ pid_t child = forkpty( &master, NULL, NULL, &window_size );
if ( child == -1 ) {
perror( "forkpty" );
@@ -444,6 +435,22 @@ int run_server( const char *desired_ip, const char *desired_port,
/* close server-related file descriptors */
delete network;
+ /* set IUTF8 if available */
+#ifdef HAVE_IUTF8
+ struct termios child_termios;
+ if ( tcgetattr( STDIN_FILENO, &child_termios ) < 0 ) {
+ perror( "tcgetattr" );
+ exit( 1 );
+ }
+
+ child_termios.c_iflag |= IUTF8;
+
+ if ( tcsetattr( STDIN_FILENO, TCSANOW, &child_termios ) < 0 ) {
+ perror( "tcsetattr" );
+ exit( 1 );
+ }
+#endif /* HAVE_IUTF8 */
+
/* set TERM */
const char default_term[] = "xterm";
const char color_term[] = "xterm-256color";
Please sign in to comment.
Something went wrong with that request. Please try again.