From 8cefc5390822c8fb110439b366ea6226b5eddd27 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 20 Aug 2014 21:15:46 +0200 Subject: add --immortal option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-base.c | 12 ++++++++++-- src/mds-base.h | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/mds-base.c b/src/mds-base.c index 429632e..dd72081 100644 --- a/src/mds-base.c +++ b/src/mds-base.c @@ -61,6 +61,12 @@ int is_respawn = -1; */ int is_reexec = 0; +/** + * Whether the server should do its + * best to resist event triggered death + */ +int is_immortal = 0; + /** * Whether to fork the process when the * server has been properly initialised @@ -133,6 +139,8 @@ int __attribute__((weak)) parse_cmdline(void) on_init_fork = 1; else if (startswith(arg, "--on-init-sh=")) /* Run a command when initialised. */ on_init_sh = arg + strlen("--on-init-sh="); + else if (strequals(arg, "--immortal")) /* I return to serve. */ + is_immortal = 1; } if (is_reexec) { @@ -598,8 +606,8 @@ int trap_signals(void) /* Implement silent interruption on SIGRTMIN. */ fail_if (xsigaction(SIGRTMIN, received_noop) < 0); - /* Implement silent interruption on SIGDANGER. */ - if (server_characteristics.danger_is_deadly) + /* Implement death on SIGDANGER or ignoral of SIGDANGER. */ + if (server_characteristics.danger_is_deadly && !is_immortal) { fail_if (xsigaction(SIGDANGER, commit_suicide) < 0); } else { fail_if (xsigaction(SIGDANGER, SIG_IGN) < 0); } diff --git a/src/mds-base.h b/src/mds-base.h index c3c6c9c..89231bf 100644 --- a/src/mds-base.h +++ b/src/mds-base.h @@ -65,7 +65,7 @@ typedef struct server_characteristics unsigned fork_for_safety : 1; /** - * Seting this to non-zero without setting a signal action + * Setting this to non-zero without setting a signal action * for `SIGDANGER` will cause the server to die if `SIGDANGER` * is received. It is safe to set both `danger_is_deadly` and * `fork_for_safety` to non-zero, during the call of @@ -73,6 +73,9 @@ typedef struct server_characteristics * in the parent process will be set to `SIG_IGN` independently * of the value of `danger_is_deadly` if `fork_for_safety` * is set to non-zero. + * + * This setting will be treated as set to zero if + * --immortal is used. */ unsigned danger_is_deadly : 1; @@ -112,6 +115,12 @@ extern int is_respawn; */ extern int is_reexec; +/** + * Whether the server should do its + * best to resist event triggered death + */ +extern int is_immortal; + /** * Whether to fork the process when the * server has been properly initialised -- cgit v1.2.3-70-g09d2