mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-06 03:50:06 +02:00
reap the exit statuses from 'onevent' child processes
This commit is contained in:
parent
a4e0f582a8
commit
eaac599ce3
3 changed files with 39 additions and 6 deletions
14
src/main.rs
14
src/main.rs
|
@ -39,6 +39,9 @@ use librespot::playback::config::{Bitrate, PlayerConfig};
|
|||
use librespot::playback::mixer::{self, Mixer};
|
||||
use librespot::playback::player::{Player, PlayerEvent};
|
||||
|
||||
mod child_wait_future;
|
||||
use child_wait_future::ChildWaitFuture;
|
||||
|
||||
mod player_event_handler;
|
||||
use player_event_handler::run_program_on_events;
|
||||
|
||||
|
@ -466,7 +469,16 @@ impl Future for Main {
|
|||
if let Some(ref mut player_event_channel) = self.player_event_channel {
|
||||
if let Async::Ready(Some(event)) = player_event_channel.poll().unwrap() {
|
||||
if let Some(ref program) = self.player_event_program {
|
||||
run_program_on_events(event, program);
|
||||
let child = run_program_on_events(event, program)
|
||||
.expect("program failed to start");
|
||||
|
||||
let wait_future = ChildWaitFuture { child }
|
||||
.map(|status| if !status.success() {
|
||||
error!("child exited with status {:?}", status.code());
|
||||
})
|
||||
.map_err(|e| error!("failed to wait on child process: {}", e));
|
||||
|
||||
self.handle.spawn(wait_future);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue