1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-19 18:57:59 +03:00

windows: gui: only attach parent console when spawned by wezterm

speculative attempt to do something about https://github.com/wez/wezterm/issues/1278
This commit is contained in:
Wez Furlong 2021-11-21 09:21:44 -07:00
parent a006f9a119
commit 3b30230d58
2 changed files with 14 additions and 2 deletions

View File

@ -72,6 +72,11 @@ struct Opt {
number_of_values = 1)]
config_override: Vec<(String, String)>,
/// On Windows, whether to attempt to attach to the parent
/// process console to display logging output
#[structopt(long = "attach-parent-console")]
attach_parent_console: bool,
#[structopt(subcommand)]
cmd: Option<SubCommand>,
}
@ -585,6 +590,8 @@ fn run() -> anyhow::Result<()> {
}
}
let opts = Opt::from_args();
// This is a bit gross.
// In order to not to automatically open a standard windows console when
// we run, we use the windows_subsystem attribute at the top of this
@ -598,7 +605,9 @@ fn run() -> anyhow::Result<()> {
// input but didn't know to re-draw the prompt.
#[cfg(windows)]
unsafe {
winapi::um::wincon::AttachConsole(winapi::um::wincon::ATTACH_PARENT_PROCESS);
if opts.attach_parent_console {
winapi::um::wincon::AttachConsole(winapi::um::wincon::ATTACH_PARENT_PROCESS);
}
};
env_bootstrap::bootstrap();
@ -606,7 +615,6 @@ fn run() -> anyhow::Result<()> {
stats::Stats::init()?;
let _saver = umask::UmaskSaver::new();
let opts = Opt::from_args();
config::common_init(
opts.config_file.as_ref(),
&opts.config_override,

View File

@ -342,6 +342,10 @@ fn delegate_to_gui(saver: UmaskSaver) -> anyhow::Result<()> {
let mut cmd = Command::new(exe);
cmd.args(std::env::args_os().skip(1));
if cfg!(windows) {
cmd.arg("--attach-parent-console");
}
#[cfg(unix)]
{
use std::os::unix::process::CommandExt;