From 59e5074127232637369560657d5cb32bf342737c Mon Sep 17 00:00:00 2001 From: g Date: Mon, 4 Nov 2024 15:33:10 +0100 Subject: [PATCH 1/2] nsm.h: change getpid to geppid Adljack starts itself in a terminal application. The terminal application obtains the same pid as is started by the NSM daemon. This is the pid the NSM Daemon 'owns'. To announce with the same pid as the process started by the NSM daemon, it's needed to use getppid (get parent pid), this is the pid of the terminal, whereas getpid gets us the pid of adljack. --- thirdparty/nonlib/nsm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thirdparty/nonlib/nsm.h b/thirdparty/nonlib/nsm.h index b506cd3..9f7819f 100644 --- a/thirdparty/nonlib/nsm.h +++ b/thirdparty/nonlib/nsm.h @@ -240,7 +240,8 @@ nsm_send_announce ( nsm_client_t *nsm, const char *app_name, const char *capabil return; } - int pid = (int)getpid(); + // int pid = (int)getpid(); + int pid = (int)getppid(); lo_send_from( to, _NSM()->_server, LO_TT_IMMEDIATE, "/nsm/server/announce", "sssiii", app_name, From a8fcb52a90524a49e0420acc4f7ab024f74bf93c Mon Sep 17 00:00:00 2001 From: g Date: Mon, 4 Nov 2024 15:42:44 +0100 Subject: [PATCH 2/2] common.cc: add SIGHUP to signals When under NSM session management, a NSM clients needs to exite when it gets a SIGTERM signal from the NSM daemon. The case of adljack is a special one, as it launches itself in a terminal application. To match the pid process of the NSM daemon when it starts adljack, the pid of the terminal application is send (parent pid). So the terminal applications get the SIGTERM signal from the NSM daemon. SIGHUP is a signal sent to a process when its controlled terminal is closed. So by adding SIGHUP to the catched signals, adljack exites when the terminal application adljack is launched in, gets a SIGTERM signal. --- sources/common.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/common.cc b/sources/common.cc index 1ba8b92..0387005 100644 --- a/sources/common.cc +++ b/sources/common.cc @@ -587,7 +587,7 @@ void handle_signals() int nsignal = 0; sigemptyset(&sigs); - for (int signo : {SIGINT, SIGTERM}) { + for (int signo : {SIGINT, SIGTERM, SIGHUP}) { sigaddset(&sigs, signo); nsignal = signo + 1; }