From: Davin McCall Date: Fri, 8 Jun 2018 20:04:58 +0000 (+0100) Subject: Fix bug causing scripted service shutdown scripts to be run twice. X-Git-Tag: v0.2.0~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6b4db8c574fe450b3cdc953b51b88dce692f13c9;p=oweals%2Fdinit.git Fix bug causing scripted service shutdown scripts to be run twice. All tests now passing. --- diff --git a/src/includes/proc-service.h b/src/includes/proc-service.h index 76fef21..bccce7a 100644 --- a/src/includes/proc-service.h +++ b/src/includes/proc-service.h @@ -267,6 +267,7 @@ class bgproc_service : public base_process_service class scripted_service : public base_process_service { virtual void handle_exit_status(bp_sys::exit_status exit_status) noexcept override; + virtual void exec_succeeded() noexcept override; virtual void exec_failed(int errcode) noexcept override; virtual void bring_down() noexcept override; diff --git a/src/proc-service.cc b/src/proc-service.cc index d482fde..7651ec7 100644 --- a/src/proc-service.cc +++ b/src/proc-service.cc @@ -55,6 +55,12 @@ void process_service::exec_succeeded() noexcept } } +void scripted_service::exec_succeeded() noexcept +{ + // For a scripted service, this means nothing other than that the start/stop + // script will now begin. +} + rearm exec_status_pipe_watcher::fd_event(eventloop_t &loop, int fd, int flags) noexcept { base_process_service *sr = service; @@ -506,6 +512,11 @@ void bgproc_service::bring_down() noexcept void scripted_service::bring_down() noexcept { + if (pid != -1) { + // We're already running the stop script; nothing to do. + return; + } + if (stop_command.length() == 0) { stopped(); }