return r;
}
+void process_service::exec_succeeded() noexcept
+{
+ // This could be a smooth recovery (state already STARTED). Even more, the process
+ // might be stopped (and killed via a signal) during smooth recovery. We don't to
+ // process startup again in either case, so we check for state STARTING:
+ if (get_state() == service_state_t::STARTING) {
+ started();
+ }
+ else if (get_state() == service_state_t::STOPPING) {
+ // stopping, but smooth recovery was in process. That's now over so we can
+ // commence normal stop. Note that if pid == -1 the process already stopped(!),
+ // that's handled below.
+ if (pid != -1 && stop_check_dependents()) {
+ bring_down();
+ }
+ }
+}
+
rearm exec_status_pipe_watcher::fd_event(eventloop_t &loop, int fd, int flags) noexcept
{
base_process_service *sr = service;
sr->exec_failed(exec_status);
}
else {
- // exec() succeeded.
- if (sr->get_type() == service_type_t::PROCESS) {
- // This could be a smooth recovery (state already STARTED). Even more, the process
- // might be stopped (and killed via a signal) during smooth recovery. We don't to
- // process startup again in either case, so we check for state STARTING:
- if (sr->get_state() == service_state_t::STARTING) {
- sr->started();
- }
- else if (sr->get_state() == service_state_t::STOPPING) {
- // stopping, but smooth recovery was in process. That's now over so we can
- // commence normal stop. Note that if pid == -1 the process already stopped(!),
- // that's handled below.
- if (sr->pid != -1 && sr->stop_check_dependents()) {
- sr->bring_down();
- }
- }
- }
+ sr->exec_succeeded();
if (sr->pid == -1) {
- // Somehow the process managed to complete before we even saw the status.
+ // Somehow the process managed to complete before we even saw the exec() status.
sr->handle_exit_status(sr->exit_status);
}
}
// Called if an exec fails.
virtual void exec_failed(int errcode) noexcept = 0;
+ // Called if exec succeeds.
+ virtual void exec_succeeded() noexcept { };
+
virtual bool can_interrupt_start() noexcept override
{
return waiting_restart_timer || start_is_interruptible || service_record::can_interrupt_start();
{
virtual void handle_exit_status(int exit_status) noexcept override;
virtual void exec_failed(int errcode) noexcept override;
+ virtual void exec_succeeded() noexcept override;
virtual void bring_down() noexcept override;
public: