mosh-client: return meaningful exitstatus on network setup/teardown or other failure
This commit is contained in:
@@ -163,12 +163,13 @@ int main( int argc, char *argv[] )
|
|||||||
/* Adopt native locale */
|
/* Adopt native locale */
|
||||||
set_native_locale();
|
set_native_locale();
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
try {
|
try {
|
||||||
STMClient client( ip, desired_port, key, predict_mode );
|
STMClient client( ip, desired_port, key, predict_mode );
|
||||||
client.init();
|
client.init();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.main();
|
success = client.main();
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
client.shutdown();
|
client.shutdown();
|
||||||
throw;
|
throw;
|
||||||
@@ -178,16 +179,19 @@ int main( int argc, char *argv[] )
|
|||||||
} catch ( const Network::NetworkException &e ) {
|
} catch ( const Network::NetworkException &e ) {
|
||||||
fprintf( stderr, "Network exception: %s\r\n",
|
fprintf( stderr, "Network exception: %s\r\n",
|
||||||
e.what() );
|
e.what() );
|
||||||
|
success = false;
|
||||||
} catch ( const Crypto::CryptoException &e ) {
|
} catch ( const Crypto::CryptoException &e ) {
|
||||||
fprintf( stderr, "Crypto exception: %s\r\n",
|
fprintf( stderr, "Crypto exception: %s\r\n",
|
||||||
e.what() );
|
e.what() );
|
||||||
|
success = false;
|
||||||
} catch ( const std::exception &e ) {
|
} catch ( const std::exception &e ) {
|
||||||
fprintf( stderr, "Error: %s\r\n", e.what() );
|
fprintf( stderr, "Error: %s\r\n", e.what() );
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( "\n[mosh is exiting.]\n" );
|
printf( "\n[mosh is exiting.]\n" );
|
||||||
|
|
||||||
free( key );
|
free( key );
|
||||||
|
|
||||||
return 0;
|
return !success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ bool STMClient::process_resize( void )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STMClient::main( void )
|
bool STMClient::main( void )
|
||||||
{
|
{
|
||||||
/* initialize signal handling and structures */
|
/* initialize signal handling and structures */
|
||||||
main_init();
|
main_init();
|
||||||
@@ -479,7 +479,7 @@ void STMClient::main( void )
|
|||||||
|
|
||||||
if ( sel.signal( SIGWINCH ) ) {
|
if ( sel.signal( SIGWINCH ) ) {
|
||||||
/* resize */
|
/* resize */
|
||||||
if ( !process_resize() ) { return; }
|
if ( !process_resize() ) { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( sel.signal( SIGCONT ) ) {
|
if ( sel.signal( SIGCONT ) ) {
|
||||||
@@ -572,5 +572,6 @@ void STMClient::main( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return clean_shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public:
|
|||||||
|
|
||||||
void init( void );
|
void init( void );
|
||||||
void shutdown( void );
|
void shutdown( void );
|
||||||
void main( void );
|
bool main( void );
|
||||||
|
|
||||||
~STMClient()
|
~STMClient()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user