From 0835ca284ee09a8724e96f4dfb329024e7bcb418 Mon Sep 17 00:00:00 2001 From: Nils Date: Mon, 1 Aug 2022 01:55:48 +0200 Subject: [PATCH] Absolutely make sure that all clients of the session are closed when closing the session. This solves the invisible, hidden clients still running even after nsmd quit itself. Also Decrease wait time for such clients at session quit from extreme 60s to very long 30s. --- CHANGELOG | 6 ++++++ src/nsmd.cpp | 33 ++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7186e4f..634a88b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,12 @@ Two empty lines before the next entry. External contributors notice at the end of the line: (LastName, FirstName / nick) +## 2022-10-15 1.6.1 +Absolutely make sure that all clients of the session are closed when closing the session. + This solves the invisible, hidden clients still running even after nsmd quit itself. + Decrease wait time for such clients at session quit from extreme 60s to very long 30s. + + ## 2022-04-15 1.6.0 nsmd: Now follows the XDG Base Directory Specifications. diff --git a/src/nsmd.cpp b/src/nsmd.cpp index 994d263..7499ca0 100644 --- a/src/nsmd.cpp +++ b/src/nsmd.cpp @@ -1158,12 +1158,14 @@ wait_for_killed_clients_to_die ( ) { struct signalfd_siginfo fdsi; - MESSAGE( "Waiting for killed clients to die." ); - - for ( int i = 0; i < 60; i++ ) + MESSAGE( "Waiting 30 seconds for killed clients to die." ); + for ( int i = 0; i < 30; i++ ) { if ( ! killed_clients_are_alive() ) - goto done; + { + MESSAGE( "All clients have died." ); + return; + } ssize_t s = read(signal_fd, &fdsi, sizeof(struct signalfd_siginfo)); @@ -1181,13 +1183,26 @@ wait_for_killed_clients_to_die ( ) sleep(1); } - WARNING( "Killed clients are still alive" ); + /* The clients that are still alive are dangerous to the user. + * Their GUI will be most likely hidden or non-responsive, their jack client still open. + * And now the session will close, maybe even nsmd will quit. The hanging process is left + * open and invisible to the user. As a last resort it must be killed until we lose control over + * the process. + */ + WARNING( "Killed clients are still alive" ); + std::list *cl = &client; + for ( std::list::iterator i = cl->begin(); + i != cl->end(); + ++i ) + { + if ( (*i)->pid > 0 ) + { + WARNING( "SIGKILL to: %s", (*i)->name_with_id ); + kill( (*i)->pid, SIGKILL ); + } + } return; - -done: - - MESSAGE( "All clients have died." ); }