diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-02-08 16:40:02 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-02-08 16:40:02 +0100 |
| commit | 7aa4ead921e41a7b8c3e078838013fc690c06dc6 (patch) | |
| tree | df758c0ad4cfd5d2f9bcd77bbbe5fa22eb6f728a /src/process | |
| parent | 3738df928c5b49a564e067b584c442fd66edfc01 (diff) | |
| download | mullvadvpn-7aa4ead921e41a7b8c3e078838013fc690c06dc6.tar.xz mullvadvpn-7aa4ead921e41a7b8c3e078838013fc690c06dc6.zip | |
Stop using foreign_link in an invalid(?) way
Diffstat (limited to 'src/process')
| -rw-r--r-- | src/process/monitor.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/process/monitor.rs b/src/process/monitor.rs index 3553f783cf..8caac5cc79 100644 --- a/src/process/monitor.rs +++ b/src/process/monitor.rs @@ -11,9 +11,14 @@ error_chain! { InvalidState { description("Invalid state for desired transition") } - } - foreign_links { - Io(::std::io::Error) #[doc = "The monitor state transition failed because of an IO error"]; + /// Error representing a failure in spawning the child process + Spawn { + description("Unable to spawn child process") + } + /// Error representing a failure in sending a kill signal to the child process + Kill { + description("Unable to send kill signal to process") + } } } @@ -77,7 +82,7 @@ impl<S: ChildSpawner> ChildMonitor<S> { { let mut state_lock = self.state.lock().unwrap(); if let State::Stopped = *state_lock { - let mut child = self.spawner.spawn()?; + let mut child = self.spawner.spawn().chain_err(|| ErrorKind::Spawn)?; let io = (child.stdout(), child.stderr()); let thread_handle = self.spawn_monitor(child.clone(), listener); *state_lock = State::Running(RunningState { @@ -108,7 +113,7 @@ impl<S: ChildSpawner> ChildMonitor<S> { pub fn stop(&self) -> Result<()> { let state_lock = self.state.lock().unwrap(); if let State::Running(ref running_state) = *state_lock { - running_state.child.kill()?; + running_state.child.kill().chain_err(|| ErrorKind::Kill)?; Ok(()) } else { Err(ErrorKind::InvalidState.into()) |
