From 299193dc60dd5728ba6b75ac912bffa7314420c4 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 4 Apr 2013 20:01:19 -0700 Subject: [PATCH] NSM: Further clarify nsmd debugging output regarding client death. --- session-manager/src/nsmd.C | 70 ++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/session-manager/src/nsmd.C b/session-manager/src/nsmd.C index 85696a6..a4e0a74 100644 --- a/session-manager/src/nsmd.C +++ b/session-manager/src/nsmd.C @@ -302,39 +302,37 @@ handle_client_process_death ( int pid ) if ( c ) { - - bool dead_because_we_said = false; - - if ( c->pending_command() == COMMAND_KILL || - c->pending_command() == COMMAND_QUIT ) - { - dead_because_we_said = true; - } - - - c->pending_command( COMMAND_NONE ); - - c->active = false; - c->pid = 0; + bool dead_because_we_said = ( c->pending_command() == COMMAND_KILL || + c->pending_command() == COMMAND_QUIT ); if ( dead_because_we_said ) { MESSAGE( "Client %s terminated because we told it to.", c->name ); - if ( gui_is_active ) - osc_server->send( gui_addr, "/nsm/gui/client/status", c->client_id, c->status = "removed" ); - - client.remove( c ); - - delete c; } else { MESSAGE( "Client %s died unexpectedly.", c->name ); + } + if ( c->pending_command() == COMMAND_QUIT ) + { + if ( gui_is_active ) + osc_server->send( gui_addr, "/nsm/gui/client/status", c->client_id, c->status = "removed" ); + + client.remove(c); + delete c; + } + else + { if ( gui_is_active ) osc_server->send( gui_addr, "/nsm/gui/client/status", c->client_id, c->status = "stopped" ); } - } + + c->pending_command( COMMAND_NONE ); + + c->active = false; + c->pid = 0; + } } @@ -995,6 +993,21 @@ command_all_clients_to_save ( ) } } +void +command_client_to_stop ( Client *c ) +{ + MESSAGE( "Stopping client %s", c->name ); + + if ( c->pid > 0 ) + { + c->pending_command( COMMAND_KILL ); + + kill( c->pid, SIGTERM ); + + if ( gui_is_active ) + osc_server->send( gui_addr, "/nsm/gui/client/status", c->client_id, c->status = "stopped" ); + } +} void command_client_to_quit ( Client *c ) @@ -1015,10 +1028,10 @@ command_client_to_quit ( Client *c ) if ( c->pid > 0 ) { if ( gui_is_active ) - osc_server->send( gui_addr, "/nsm/gui/client/status", c->client_id, c->status = "kill" ); + osc_server->send( gui_addr, "/nsm/gui/client/status", c->client_id, c->status = "quit" ); /* should be kill? */ - c->pending_command( COMMAND_KILL ); + c->pending_command( COMMAND_QUIT ); // this is a dumb client... try and kill it kill( c->pid, SIGTERM ); @@ -1897,13 +1910,10 @@ OSC_HANDLER( stop ) if ( c ) { - if ( c->pid != 0 ) - { - kill( c->pid, SIGTERM ); - - if ( gui_is_active ) - osc_server->send( gui_addr, "/reply", "Client stopped." ); - } + command_client_to_stop( c ); + + if ( gui_is_active ) + osc_server->send( gui_addr, "/reply", "Client stopped." ); } else {