From d636845c8d2e7cde2303e5fa30a3bc6562080593 Mon Sep 17 00:00:00 2001 From: Jaeho Shin Date: Sat, 2 Apr 2016 02:55:38 -0700 Subject: [PATCH] Display original command line argv via no-op flag. Improves 679b819216e1946ebe3a6f920c0fbf61d61ab47e to make it simpler to ignore mosh-client from OS X Terminal.app's "Ask before closing" process list. (See: http://superuser.com/a/254647) Moreover, the command displayed from ps is a completely functional one, which was not the case in the previous approach, that mangles `argv[0]`. Fixes #742. --- scripts/mosh.pl | 2 +- src/frontend/mosh-client.cc | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/mosh.pl b/scripts/mosh.pl index 375906b..c6fc632 100755 --- a/scripts/mosh.pl +++ b/scripts/mosh.pl @@ -431,7 +431,7 @@ if ( $pid == 0 ) { # child $ENV{ 'MOSH_KEY' } = $key; $ENV{ 'MOSH_PREDICTION_DISPLAY' } = $predict; $ENV{ 'MOSH_NO_TERM_INIT' } = '1' if !$term_init; - exec {$client} ("$client @cmdline |", $ip, $port); + exec {$client} ("$client", "-# @cmdline |", $ip, $port); } sub shell_quote { join ' ', map {(my $a = $_) =~ s/'/'\\''/g; "'$a'"} @_ } diff --git a/src/frontend/mosh-client.cc b/src/frontend/mosh-client.cc index 6afb6e1..7efa161 100644 --- a/src/frontend/mosh-client.cc +++ b/src/frontend/mosh-client.cc @@ -75,7 +75,7 @@ static void usage( const char *argv0 ) { fprintf( stderr, "Copyright 2012 Keith Winstein \n" ); fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later .\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" ); - fprintf( stderr, "Usage: %s IP PORT\n %s -c\n", argv0, argv0 ); + fprintf( stderr, "Usage: %s [-# 'ARGS'] IP PORT\n %s -c\n", argv0, argv0 ); } static void print_colorcount( void ) @@ -107,8 +107,11 @@ int main( int argc, char *argv[] ) /* Get arguments */ int opt; - while ( (opt = getopt( argc, argv, "c" )) != -1 ) { + while ( (opt = getopt( argc, argv, "#:c" )) != -1 ) { switch ( opt ) { + case '#': + // Ignore the original arguments to mosh wrapper + break; case 'c': print_colorcount(); exit( 0 );