diff options
author | Björn-Egil Dahlberg <[email protected]> | 2015-04-20 14:43:53 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2015-04-20 14:43:53 +0200 |
commit | 5dead30ea35a1cd97ebc8dd8f12e27f0a27348af (patch) | |
tree | 2d2c8607beafcf3208b6ee60080b51b9fb25cda5 /erts/etc/common/heart.c | |
parent | ddfbbcbbd489913120a55b2a054b046c68b40a8a (diff) | |
download | otp-5dead30ea35a1cd97ebc8dd8f12e27f0a27348af.tar.gz otp-5dead30ea35a1cd97ebc8dd8f12e27f0a27348af.tar.bz2 otp-5dead30ea35a1cd97ebc8dd8f12e27f0a27348af.zip |
erts: Enable different abort signal from heart
By using environment variable HEART_KILL_SIGNAL, heart can now use
a different signal to kill the old running Erlang.
By default the signal is SIGKILL but SIGABRT may also be used by
setting environment variable: HEART_KILL_SIGNAL=SIGABRT
Diffstat (limited to 'erts/etc/common/heart.c')
-rw-r--r-- | erts/etc/common/heart.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/erts/etc/common/heart.c b/erts/etc/common/heart.c index a4f34e21d0..0d1dcacf2c 100644 --- a/erts/etc/common/heart.c +++ b/erts/etc/common/heart.c @@ -117,11 +117,12 @@ #define HEART_COMMAND_ENV "HEART_COMMAND" #define ERL_CRASH_DUMP_SECONDS_ENV "ERL_CRASH_DUMP_SECONDS" +#define HEART_KILL_SIGNAL "HEART_KILL_SIGNAL" -#define MSG_HDR_SIZE 2 -#define MSG_HDR_PLUS_OP_SIZE 3 -#define MSG_BODY_SIZE 2048 -#define MSG_TOTAL_SIZE 2050 +#define MSG_HDR_SIZE (2) +#define MSG_HDR_PLUS_OP_SIZE (3) +#define MSG_BODY_SIZE (2048) +#define MSG_TOTAL_SIZE (2050) unsigned char cmd[MSG_BODY_SIZE]; @@ -555,14 +556,22 @@ kill_old_erlang(void){ static void kill_old_erlang(void){ pid_t pid; - int i; - int res; + int i, res; + int sig = SIGKILL; + char *sigenv = NULL; + + sigenv = get_env(HEART_KILL_SIGNAL); + if (sigenv && strcmp(sigenv, "SIGABRT") == 0) { + print_error("kill signal SIGABRT requested"); + sig = SIGABRT; + } + if(heart_beat_kill_pid != 0){ pid = (pid_t) heart_beat_kill_pid; - res = kill(pid,SIGKILL); + res = kill(pid,sig); for(i=0; i < 5 && res == 0; ++i){ sleep(1); - res = kill(pid,SIGKILL); + res = kill(pid,sig); } if(errno != ESRCH){ print_error("Unable to kill old process, " |