// In most cases, the rest is done in handle_exit_status.
// If we are a BGPROCESS and the process is not our immediate child, however, that
// won't work - check for this now:
- if (record_type == service_type::BGPROCESS) {
- // TODO use 'tracking_child' instead
- int status;
- pid_t r = waitpid(pid, &status, WNOHANG);
- if (r == -1 && errno == ECHILD) {
- // We can't track this child (or it's terminated already)
- stopped();
- }
- else if (r == pid) {
- // Process may have died due to signal since we explicitly requested it to
- // stop by signalling it; no need to log any termination status.
- stopped();
- }
+ if (record_type == service_type::BGPROCESS && ! tracking_child) {
+ stopped();
}
}
else {
waiting_restart_timer = false;
reserved_child_watch = false;
+ tracking_child = false;
}
void base_process_service::do_restart() noexcept
service_child_watcher child_listener;
exec_status_pipe_watcher child_status_listener;
process_restart_timer restart_timer;
- timespec last_start_time;
+ time_val last_start_time;
// Restart interval time and restart count are used to track the number of automatic restarts
// over an interval. Too many restarts over an interval will inhibit further restarts.
- timespec restart_interval_time;
+ time_val restart_interval_time;
int restart_interval_count;
timespec restart_interval;
bool waiting_restart_timer : 1;
bool reserved_child_watch : 1;
+ bool tracking_child : 1;
// Start the process, return true on success
virtual bool start_ps_process() noexcept override;
bool doing_recovery : 1; // if we are currently recovering a BGPROCESS (restarting process, while
// holding STARTED service state)
- bool tracking_child : 1;
enum class pid_result_t {
OK,