From 1af4ecfc266ca05b1c370268828034e071859dec Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 19 Nov 2013 20:56:22 +0800 Subject: [PATCH] win: Make console output work on cygwin. --- app/atom_main.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/atom_main.cc b/app/atom_main.cc index 5795418..2b0366d 100644 --- a/app/atom_main.cc +++ b/app/atom_main.cc @@ -34,15 +34,19 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) { int argc = 0; wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); - // Attach to the parent console if we've got one so that stdio works - AttachConsole(ATTACH_PARENT_PROCESS); + scoped_ptr env(base::Environment::Create()); - FILE* dontcare; - freopen_s(&dontcare, "CON", "w", stdout); - freopen_s(&dontcare, "CON", "w", stderr); - freopen_s(&dontcare, "CON", "r", stdin); + // Make output work in console if we are not in cygiwn. + std::string os; + if (env->GetVar("OS", &os) && os != "cygwin") { + AttachConsole(ATTACH_PARENT_PROCESS); + + FILE* dontcare; + freopen_s(&dontcare, "CON", "w", stdout); + freopen_s(&dontcare, "CON", "w", stderr); + freopen_s(&dontcare, "CON", "r", stdin); + } - scoped_ptr env(base::Environment::Create()); std::string node_indicator; if (env->GetVar("ATOM_SHELL_INTERNAL_RUN_AS_NODE", &node_indicator) && node_indicator == "1") { -- 2.7.4