Skip to content

Commit

Permalink
Fix spawning excessive conhost processes on Windows (mozilla#1143)
Browse files Browse the repository at this point in the history
Fixes mozilla#514 (comment) (comment 2022-03-08 by @mitchhentges)

Any console-based subprocess spawned with CREATE_NO_WINDOW actually has a hidden console, and thus an associated conhost process. Since the sccache server is already started with CREATE_NO_WINDOW, it's unnecessary to spawn further subprocesses with CREATE_NO_WINDOW. Removing this flag allows subprocesses to share the sccache server's hidden console, thus avoiding each subprocess from getting its own conhost.

For an extended explanation see this comment and its follow-ups:
mozilla#514 (comment)
  • Loading branch information
FooBarWidget authored and emabrey committed Aug 10, 2022
1 parent 8e55447 commit 4af46b5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
18 changes: 0 additions & 18 deletions src/mock_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ pub trait RunCommand: fmt::Debug + Send {
fn env_clear(&mut self) -> &mut Self;
/// Set the working directory of the process to `dir`.
fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut Self;
/// Create the proces without a visible console on Windows.
fn no_console(&mut self) -> &mut Self;
/// Set the process' stdin from `cfg`.
fn stdin(&mut self, cfg: Stdio) -> &mut Self;
/// Set the process' stdout from `cfg`.
Expand Down Expand Up @@ -237,19 +235,6 @@ impl RunCommand for AsyncCommand {
self
}

#[cfg(windows)]
fn no_console(&mut self) -> &mut AsyncCommand {
use std::os::windows::process::CommandExt;
const CREATE_NO_WINDOW: u32 = 0x08000000;
self.inner().creation_flags(CREATE_NO_WINDOW);
self
}

#[cfg(unix)]
fn no_console(&mut self) -> &mut AsyncCommand {
self
}

fn stdin(&mut self, cfg: Stdio) -> &mut AsyncCommand {
self.inner().stdin(cfg);
self
Expand Down Expand Up @@ -474,9 +459,6 @@ impl RunCommand for MockCommand {
//TODO: assert value of dir
self
}
fn no_console(&mut self) -> &mut MockCommand {
self
}
fn stdin(&mut self, _cfg: Stdio) -> &mut MockCommand {
self
}
Expand Down
1 change: 0 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ where
C: RunCommand,
{
let child = command
.no_console()
.stdin(if input.is_some() {
Stdio::piped()
} else {
Expand Down

0 comments on commit 4af46b5

Please sign in to comment.