From ed75ab869d1f7660920b56aacd4fd2f24f7b11e6 Mon Sep 17 00:00:00 2001 From: Erki Aring Date: Fri, 12 Oct 2018 22:34:57 +0300 Subject: [PATCH] Clean up zombies of 'onevent' programs --- src/player_event_handler.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/player_event_handler.rs b/src/player_event_handler.rs index b6a653dd..f9eb8e21 100644 --- a/src/player_event_handler.rs +++ b/src/player_event_handler.rs @@ -1,15 +1,19 @@ use librespot::playback::player::PlayerEvent; use std::collections::HashMap; use std::process::Command; +use std::thread; fn run_program(program: &str, env_vars: HashMap<&str, String>) { let mut v: Vec<&str> = program.split_whitespace().collect(); info!("Running {:?} with environment variables {:?}", v, env_vars); - Command::new(&v.remove(0)) + let mut child = Command::new(&v.remove(0)) .args(&v) .envs(env_vars.iter()) .spawn() .expect("program failed to start"); + thread::spawn(move || { + child.wait().expect("failed to wait for program to finish"); + }); } pub fn run_program_on_events(event: PlayerEvent, onevent: &str) {