Skip to content

Commit

Permalink
Fix zombie process on MacOS
Browse files Browse the repository at this point in the history
Signed-off-by: Thibault Meyer <meyer.thibault@gmail.com>
  • Loading branch information
thibaultmeyer committed Nov 8, 2023
1 parent f5dfdab commit 2ba6175
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/bingwallpaper/bingwallpaperchanger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,21 @@ impl BingWallpaperChanger {
// the new wallpaper is the same as the old one.
let tmp_filename = format!("/tmp/{0}", self.get_date_system());
fs::copy(self.configuration.target_filename.as_str(), &tmp_filename).unwrap();
Command::new("swift")
let mut child = Command::new("swift")
.arg("/tmp/bingwallpaper.swift")
.arg(&tmp_filename)
.spawn()
.expect("Can't change wallpaper");
child.wait().expect("Can't wait for child process");
std::thread::sleep(std::time::Duration::from_millis(250));

// Uses the real file
Command::new("swift")
let mut child = Command::new("swift")
.arg("/tmp/bingwallpaper.swift")
.arg(&self.configuration.target_filename)
.spawn()
.expect("Can't change wallpaper");
child.wait().expect("Can't wait for child process");

std::thread::sleep(std::time::Duration::from_secs(1));
fs::remove_file(&tmp_filename).unwrap();
Expand Down

0 comments on commit 2ba6175

Please sign in to comment.