diff options
author | Zac Pullar-Strecker <zacmps@gmail.com> | 2018-10-18 15:58:58 +1300 |
---|---|---|
committer | Zac Pullar-Strecker <zacps@users.noreply.github.com> | 2018-10-18 17:01:50 +1300 |
commit | a7e59d393d5ca93383b84d8ff7f2b912ba10c5b2 (patch) | |
tree | ea12757e0b4a8ef4d59865a325ed7531dc830858 | |
parent | f3a76e24f1b8e70050e106fa4b68bf582b7bf558 (diff) | |
download | alacritty-a7e59d393d5ca93383b84d8ff7f2b912ba10c5b2.tar.gz alacritty-a7e59d393d5ca93383b84d8ff7f2b912ba10c5b2.zip |
Attach to the console of the parent process on windows
This fixes not seeing console output on windows release builds.
-rw-r--r-- | src/main.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 651c5abd..c6b15b72 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ // window for the program. // This is silently ignored on non-windows systems. // See https://msdn.microsoft.com/en-us/library/4cc7ya5b.aspx for more details. -#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] +#![windows_subsystem = "windows"] #[macro_use] extern crate alacritty; @@ -33,11 +33,18 @@ extern crate dirs; use std::error::Error; use std::sync::Arc; + #[cfg(target_os = "macos")] use std::env; + #[cfg(not(windows))] use std::os::unix::io::AsRawFd; +#[cfg(windows)] +extern crate winapi; +#[cfg(windows)] +use winapi::um::wincon::{AttachConsole, ATTACH_PARENT_PROCESS}; + use alacritty::cli; use alacritty::config::{self, Config}; use alacritty::display::Display; @@ -52,6 +59,12 @@ use alacritty::tty::{self, process_should_exit}; use alacritty::util::fmt::Red; fn main() { + // When linked with the windows subsystem windows won't automatically attach + // to the console of the parent process, so we do it explicitly. This fails + // silently if the parent has no console. + #[cfg(windows)] + unsafe {AttachConsole(ATTACH_PARENT_PROCESS);} + // Load command line options and config let options = cli::Options::load(); let config = load_config(&options).update_dynamic_title(&options); |