send any signal instead of SIGTERM

This commit is contained in:
Alexey Avramov 2019-01-12 04:25:25 +09:00
parent f03e4dc8bc
commit 267c78dbc5
2 changed files with 13 additions and 5 deletions

8
nohang
View File

@ -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:

View File

@ -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
#####################################################################