supervise-daemon: fix our status when we give up on the child process

This commit is contained in:
William Hubbs 2017-05-11 11:32:24 -05:00
parent 4c89e3f5fa
commit df027ca472

View File

@ -676,10 +676,12 @@ int main(int argc, char **argv)
* result would be the same. */ * result would be the same. */
if (pidfile && exists(pidfile)) if (pidfile && exists(pidfile))
unlink(pidfile); unlink(pidfile);
if (svcname) if (svcname) {
rc_service_daemon_set(svcname, exec, rc_service_daemon_set(svcname, exec,
(const char *const *)argv, (const char *const *)argv,
pidfile, false); pidfile, false);
rc_service_mark(svcname, RC_SERVICE_STOPPED);
}
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -780,6 +782,14 @@ int main(int argc, char **argv)
} }
} }
if (pidfile && exists(pidfile))
unlink(pidfile);
if (svcname) {
rc_service_daemon_set(svcname, exec,
(const char *const *)argv,
pidfile, false);
rc_service_mark(svcname, RC_SERVICE_STOPPED);
}
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else if (child_pid == 0) } else if (child_pid == 0)
child_process(exec, argv); child_process(exec, argv);