Skip to content

Commit fbc0f7a

Browse files
committed
Auto merge of rust-lang#13669 - Veykril:jod-child, r=Veykril
Properly implement Drop for JodGroupChild
2 parents e9f6087 + c8b6fef commit fbc0f7a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

crates/flycheck/src/lib.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,21 +360,28 @@ impl FlycheckActor {
360360
}
361361
}
362362

363-
struct JodChild(GroupChild);
363+
struct JodGroupChild(GroupChild);
364+
365+
impl Drop for JodGroupChild {
366+
fn drop(&mut self) {
367+
_ = self.0.kill();
368+
_ = self.0.wait();
369+
}
370+
}
364371

365372
/// A handle to a cargo process used for fly-checking.
366373
struct CargoHandle {
367374
/// The handle to the actual cargo process. As we cannot cancel directly from with
368375
/// a read syscall dropping and therefore terminating the process is our best option.
369-
child: JodChild,
376+
child: JodGroupChild,
370377
thread: jod_thread::JoinHandle<io::Result<(bool, String)>>,
371378
receiver: Receiver<CargoMessage>,
372379
}
373380

374381
impl CargoHandle {
375382
fn spawn(mut command: Command) -> std::io::Result<CargoHandle> {
376383
command.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::null());
377-
let mut child = command.group_spawn().map(JodChild)?;
384+
let mut child = command.group_spawn().map(JodGroupChild)?;
378385

379386
let stdout = child.0.inner().stdout.take().unwrap();
380387
let stderr = child.0.inner().stderr.take().unwrap();

0 commit comments

Comments
 (0)