Skip to content
This repository has been archived by the owner on Apr 30, 2023. It is now read-only.

Commit

Permalink
Fix issue where shutdown was hanging on reaping child processes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dillen Meijboom committed Mar 27, 2022
1 parent 0042f3d commit def3fc2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/daemon.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::Receiver;
use std::sync::Arc;
use std::thread::sleep;
use std::time::Duration;

use anyhow::{anyhow, Result};
use nix::sys::wait::WaitStatus::StillAlive;
use nix::sys::wait::{waitpid, WaitPidFlag};

use crate::{Event, log};
use crate::service::Service;
use crate::{log, Event};

fn check_service(service: &mut Service) -> Result<()> {
if service.is_up() {
Expand Down Expand Up @@ -134,8 +135,9 @@ impl Daemon {

// Cleanup zombie processes before shutting down
loop {
if !waitpid(None, Some(WaitPidFlag::WNOHANG)).is_ok() {
break;
match waitpid(None, Some(WaitPidFlag::WNOHANG)) {
Ok(StillAlive) | Err(_) => break,
Ok(_) => continue,
}
}

Expand Down

0 comments on commit def3fc2

Please sign in to comment.