diff options
| author | bors <bors@rust-lang.org> | 2022-11-24 20:31:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-11-24 20:31:38 +0000 |
| commit | fbc0f7a771287170298d882093b3c95e91ac01d5 (patch) | |
| tree | e119da3c4e984d9bd9fa45fe559fe846718b1b3e | |
| parent | e9f60879654307d808d69450a7a731209e8a4131 (diff) | |
| parent | c8b6fef70fd77e412a665ea8a1e45b0122e68544 (diff) | |
| download | rust-fbc0f7a771287170298d882093b3c95e91ac01d5.tar.gz rust-fbc0f7a771287170298d882093b3c95e91ac01d5.zip | |
Auto merge of #13669 - Veykril:jod-child, r=Veykril
Properly implement Drop for JodGroupChild
| -rw-r--r-- | crates/flycheck/src/lib.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 8f93dad06e3..f13088cd90e 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -360,13 +360,20 @@ impl FlycheckActor { } } -struct JodChild(GroupChild); +struct JodGroupChild(GroupChild); + +impl Drop for JodGroupChild { + fn drop(&mut self) { + _ = self.0.kill(); + _ = self.0.wait(); + } +} /// A handle to a cargo process used for fly-checking. struct CargoHandle { /// The handle to the actual cargo process. As we cannot cancel directly from with /// a read syscall dropping and therefore terminating the process is our best option. - child: JodChild, + child: JodGroupChild, thread: jod_thread::JoinHandle<io::Result<(bool, String)>>, receiver: Receiver<CargoMessage>, } @@ -374,7 +381,7 @@ struct CargoHandle { impl CargoHandle { fn spawn(mut command: Command) -> std::io::Result<CargoHandle> { command.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::null()); - let mut child = command.group_spawn().map(JodChild)?; + let mut child = command.group_spawn().map(JodGroupChild)?; let stdout = child.0.inner().stdout.take().unwrap(); let stderr = child.0.inner().stderr.take().unwrap(); |
