mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Make sure to join the child
This commit is contained in:
parent
117cf0b85b
commit
80ef52f0d5
1 changed files with 25 additions and 2 deletions
|
@ -5,8 +5,9 @@
|
||||||
use std::{
|
use std::{
|
||||||
fmt,
|
fmt,
|
||||||
io::{self, BufReader},
|
io::{self, BufReader},
|
||||||
|
ops,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
process::{Command, Stdio},
|
process::{self, Command, Stdio},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -236,8 +237,9 @@ fn run_cargo(
|
||||||
mut command: Command,
|
mut command: Command,
|
||||||
on_message: &mut dyn FnMut(cargo_metadata::Message) -> bool,
|
on_message: &mut dyn FnMut(cargo_metadata::Message) -> bool,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
let mut child =
|
let child =
|
||||||
command.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null()).spawn()?;
|
command.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null()).spawn()?;
|
||||||
|
let mut child = ChildKiller(child);
|
||||||
|
|
||||||
// We manually read a line at a time, instead of using serde's
|
// We manually read a line at a time, instead of using serde's
|
||||||
// stream deserializers, because the deserializer cannot recover
|
// stream deserializers, because the deserializer cannot recover
|
||||||
|
@ -283,3 +285,24 @@ fn run_cargo(
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ChildKiller(process::Child);
|
||||||
|
|
||||||
|
impl ops::Deref for ChildKiller {
|
||||||
|
type Target = process::Child;
|
||||||
|
fn deref(&self) -> &process::Child {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ops::DerefMut for ChildKiller {
|
||||||
|
fn deref_mut(&mut self) -> &mut process::Child {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for ChildKiller {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
let _ = self.0.kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue