From 267c78dbc59b1a4892ac6859d921c11d92d16a16 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Sat, 12 Jan 2019 04:25:25 +0900 Subject: [PATCH] send any signal instead of SIGTERM --- nohang | 8 ++++---- nohang.conf | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/nohang b/nohang index fc8ecb1..a2221aa 100755 --- a/nohang +++ b/nohang @@ -682,7 +682,7 @@ def find_victim_and_send_signal(signal): if execute_the_command and signal is SIGTERM and name in etc_dict: command = etc_dict[name] - exit_status = os.system(etc_dict[name]) + exit_status = os.system(etc_dict[name].replace('$PID', pid)) if exit_status == 0: exit_status = '\033[32m0\033[0m' else: @@ -693,11 +693,11 @@ def find_victim_and_send_signal(signal): etc_info = '{}' \ '\n\033[4mImplement corrective action:\033[0m\n Execute the command: \033[4m{}\033[0m' \ '\n Exit status: {}; response time: {} ms'.format( - victim_info, command, exit_status, + victim_info, command.replace('$PID', pid), exit_status, round(response_time * 1000)) # update stat_dict - key = "Run the command '\033[35m{}\033[0m'".format(command) + key = "Run the command '\033[35m{}\033[0m'".format(command.replace('$PID', pid)) print(key) update_stat_dict_and_print(key) @@ -705,7 +705,7 @@ def find_victim_and_send_signal(signal): print(etc_info) if gui_notifications: - send_notify_etc(pid, name, command) + send_notify_etc(pid, name, command.replace('$PID', pid)) else: diff --git a/nohang.conf b/nohang.conf index 4a4e438..8fdf791 100644 --- a/nohang.conf +++ b/nohang.conf @@ -231,7 +231,15 @@ execute_the_command = True $ETC mysqld /// systemctl restart mariadb.service & $ETC php-fpm7.0 /// systemctl restart php7.0-fpm.service -$ETC foo /// exit 0 + If command will contain $PID pattern, this template ($PID) will + be replaced by PID of process which name match with RE pattern. + Exmple: + $ETC bash /// kill -KILL $PID + It is way to send any signal instead of SIGTERM. + (run `kill -L` to see list of all signals) + +$ETC bash /// kill -9 $PID +$ETC firefox-esr /// kill -SEGV $PID #####################################################################