From f5d55844abb610ea230cd2dd77341fd7eac47f92 Mon Sep 17 00:00:00 2001 From: Hongli Lai Date: Thu, 17 Mar 2022 10:07:48 +0000 Subject: [PATCH] Fix spawning excessive conhost processes on Windows Fixes https://github.com/mozilla/sccache/issues/514#issuecomment-1061945431 (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: https://github.com/mozilla/sccache/issues/514#issuecomment-1068961965 --- src/mock_command.rs | 18 ------------------ src/util.rs | 1 - 2 files changed, 19 deletions(-) diff --git a/src/mock_command.rs b/src/mock_command.rs index 13c32ddc4..81f24d5b7 100644 --- a/src/mock_command.rs +++ b/src/mock_command.rs @@ -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>(&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`. @@ -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 @@ -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 } diff --git a/src/util.rs b/src/util.rs index 60bac531b..2c907b440 100644 --- a/src/util.rs +++ b/src/util.rs @@ -254,7 +254,6 @@ where C: RunCommand, { let child = command - .no_console() .stdin(if input.is_some() { Stdio::piped() } else {