child_fds[0] = -1;
fprintf(stderr, "Child cleaned\n");
- if (child_state == CH_DIED)
+ if (child_state == CH_DIED && params->auto_restart)
start_child();
+ else if (child_state == CH_DIED)
+ child_state = CH_STOPPED;
else if (child_state == CH_STOPPING)
child_state = CH_STOPPED;
return (0);
/*--------------------------------------------------------------------*/
+static void
+tweak_auto_restart(struct cli *cli, struct parspec *par, const char *arg)
+{
+ unsigned u;
+
+ (void)par;
+ if (arg != NULL) {
+ u = strtoul(arg, NULL, 0);
+ if (u != 0 && u != 1) {
+ cli_out(cli, "Only zero and one allowed.\n");
+ cli_result(cli, CLIS_PARAM);
+ return;
+ }
+ params->auto_restart = u;
+ }
+ cli_out(cli, "%u {1 = yes, 0 = no}\n", params->auto_restart);
+}
+
+/*--------------------------------------------------------------------*/
+
/*
* Make sure to end all lines with either a space or newline of the
* formatting will go haywire.
DELAYED_EFFECT
"See getopt(3) under SO_SNDTIMEO for more information.\n"
"Default is 600 seconds. " },
-
+ { "auto_restart", tweak_auto_restart,
+ "Restart child process automatically if it dies. "
+ "1 = yes, 0 = no.\n"
+ "Default is 1. " },
{ NULL, NULL, NULL }
};
params->mem_workspace = 4096;
params->sess_timeout = 15;
params->send_timeout = 600;
+ params->auto_restart = 1;
while ((o = getopt(argc, argv, "b:df:h:p:s:t:T:Vw:")) != -1)
switch (o) {