Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't create console window when creating process #32340

Merged
merged 3 commits into from Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions patches/node/.patches
Expand Up @@ -26,3 +26,4 @@ chore_fix_-wimplicit-fallthrough.patch
test_add_fixture_trim_option.patch
fix_crash_caused_by_gethostnamew_on_windows_7.patch
fix_suppress_clang_-wdeprecated-declarations_in_libuv.patch
fix_don_t_create_console_window_when_creating_process.patch
@@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Raymond Zhao <raymondzhao@microsoft.com>
Date: Tue, 4 Jan 2022 16:11:41 -0800
Subject: fix: Don't create console window when creating process

This patch prevents console windows from being created during
execSync calls, or spawnSync calls where shell is true. Otherwise,
Windows users will see command prompts pop up for those calls.

The patch can be removed when the windowsHide parameter
rzhao271 marked this conversation as resolved.
Show resolved Hide resolved
for those calls is changed to have a default value of true.

diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc
index 1141aceae984fba6ed07cd272a79d4007b9b03fe..afd08519d7f8974adff4060513f6160519a0b6b3 100644
--- a/src/spawn_sync.cc
+++ b/src/spawn_sync.cc
@@ -810,6 +810,9 @@ Maybe<int> SyncProcessRunner::ParseOptions(Local<Value> js_value) {
if (js_win_hide->BooleanValue(isolate))
uv_process_options_.flags |= UV_PROCESS_WINDOWS_HIDE;

+ if (env()->hide_console_windows())
+ uv_process_options_.flags |= UV_PROCESS_WINDOWS_HIDE_CONSOLE;
rzhao271 marked this conversation as resolved.
Show resolved Hide resolved
+
Local<Value> js_wva =
js_options->Get(context, env()->windows_verbatim_arguments_string())
.ToLocalChecked();