GNOME Bugzilla – Bug 733960
W32: spawning a console process creates a new window when stdout is a file
Last modified: 2014-08-05 06:44:52 UTC
Currently glib obtains stdout of the parent process, then checks its type. If stdout is a console, a console spawn helper is used. Otherwise a non-console spawn helper is used. While i won't pretend to know what the goal was, i do know that this logic produces very inconvenient results when stdout is piped into a file. If stdout is a file (i.e. not a console), the parent process does, in fact, have a console attached, and the child is a console process too, then this happens: * Parent (console) checks stdout * stdout is a file * Parent spawns spawn-helper (non-console) * Spawn helper (no console) does its job and spawns the child (console) * Child is spawned. Since it's a console application, and it inherited no console from the helper, W32 creates a console for it. This results in new, empty console window appearing on screen while the child is alive. If the child is launched repeatedly (developer tools often are) and is short-lived, the DE will be unusable while this is being done, since it will have console windows appearing and disappearing rapidly. The fix is to look for a console window and use its presence to decide which helper to use. After all, I/O is completely independent of consoles, so the only logical reason for two different helpers to exist is to avoid spawning new console windows.
Created attachment 282000 [details] [review] Change W32 console detection to look at the window, not stdout Check for console window being attached to the process, not for stdout being redirected into a console window.
I'd like to hear from the developer who implemented this check to see what the rationale was, and to check whether my code covers the intended cases well enough (because currently i can only guess why this was implemented this way).
Review of attachment 282000 [details] [review]: Patch is fine with me. About the dev what does blame show?
That's tml. https://git.gnome.org/browse/glib/commit/?id=17045b64d3627dd4b9ebc5454b18137e97fbedb2 Looks like my guess was correct, and the intention was to make sure that no unneeded console windows are opened.
Attachment 282000 [details] pushed as 14f2376 - Change W32 console detection to look at the window, not stdout