Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7742077

Browse files
committed
Auto merge of rust-lang#13552 - Veykril:flycheck-process-group, r=Veykril
internal: Use a process group for flycheck Should fix rust-lang/rust-analyzer#13348
2 parents d03c1c8 + 1dcc25a commit 7742077

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

Cargo.lock

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/flycheck/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ rustc-hash = "1.1.0"
1717
serde = { version = "1.0.137", features = ["derive"] }
1818
serde_json = "1.0.86"
1919
jod-thread = "0.1.2"
20+
command-group = "1.0.8"
2021

2122
toolchain = { path = "../toolchain", version = "0.0.0" }
2223
stdx = { path = "../stdx", version = "0.0.0" }

crates/flycheck/src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ use std::{
1010
time::Duration,
1111
};
1212

13+
use command_group::{CommandGroup, GroupChild};
1314
use crossbeam_channel::{never, select, unbounded, Receiver, Sender};
1415
use paths::AbsPathBuf;
1516
use rustc_hash::FxHashMap;
1617
use serde::Deserialize;
17-
use stdx::{process::streaming_output, JodChild};
18+
use stdx::process::streaming_output;
1819

1920
pub use cargo_metadata::diagnostic::{
2021
Applicability, Diagnostic, DiagnosticCode, DiagnosticLevel, DiagnosticSpan,
@@ -359,6 +360,8 @@ impl FlycheckActor {
359360
}
360361
}
361362

363+
struct JodChild(GroupChild);
364+
362365
/// A handle to a cargo process used for fly-checking.
363366
struct CargoHandle {
364367
/// The handle to the actual cargo process. As we cannot cancel directly from with
@@ -371,10 +374,10 @@ struct CargoHandle {
371374
impl CargoHandle {
372375
fn spawn(mut command: Command) -> std::io::Result<CargoHandle> {
373376
command.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::null());
374-
let mut child = JodChild::spawn(command)?;
377+
let mut child = command.group_spawn().map(JodChild)?;
375378

376-
let stdout = child.stdout.take().unwrap();
377-
let stderr = child.stderr.take().unwrap();
379+
let stdout = child.0.inner().stdout.take().unwrap();
380+
let stderr = child.0.inner().stderr.take().unwrap();
378381

379382
let (sender, receiver) = unbounded();
380383
let actor = CargoActor::new(sender, stdout, stderr);
@@ -386,13 +389,13 @@ impl CargoHandle {
386389
}
387390

388391
fn cancel(mut self) {
389-
let _ = self.child.kill();
390-
let _ = self.child.wait();
392+
let _ = self.child.0.kill();
393+
let _ = self.child.0.wait();
391394
}
392395

393396
fn join(mut self) -> io::Result<()> {
394-
let _ = self.child.kill();
395-
let exit_status = self.child.wait()?;
397+
let _ = self.child.0.kill();
398+
let exit_status = self.child.0.wait()?;
396399
let (read_at_least_one_message, error) = self.thread.join()?;
397400
if read_at_least_one_message || exit_status.success() {
398401
Ok(())

0 commit comments

Comments
 (0)