aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-08-20 21:15:46 +0200
committerMattias Andrée <maandree@operamail.com>2014-08-20 21:15:46 +0200
commit8cefc5390822c8fb110439b366ea6226b5eddd27 (patch)
treef56ee9605aa2559b8d173f0f0ba80a7b05694165 /src
parentadd sigdanger support (diff)
downloadmds-8cefc5390822c8fb110439b366ea6226b5eddd27.tar.gz
mds-8cefc5390822c8fb110439b366ea6226b5eddd27.tar.bz2
mds-8cefc5390822c8fb110439b366ea6226b5eddd27.tar.xz
add --immortal option
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mds-base.c12
-rw-r--r--src/mds-base.h11
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
@@ -62,6 +62,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;
@@ -113,6 +116,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
*/