After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 733960 - W32: spawning a console process creates a new window when stdout is a file
W32: spawning a console process creates a new window when stdout is a file
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: win32
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-win32 maintainers
Depends on:
Blocks:
 
 
Reported: 2014-07-30 07:27 UTC by LRN
Modified: 2014-08-05 06:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Change W32 console detection to look at the window, not stdout (1.08 KB, patch)
2014-07-30 07:27 UTC, LRN
committed Details | Review

Description LRN 2014-07-30 07:27:00 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.
Comment 1 LRN 2014-07-30 07:27:04 UTC
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.
Comment 2 LRN 2014-07-30 07:28:21 UTC
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).
Comment 3 Ignacio Casal Quinteiro (nacho) 2014-07-30 09:39:06 UTC
Review of attachment 282000 [details] [review]:

Patch is fine with me. About the dev what does blame show?
Comment 4 LRN 2014-07-30 09:43:26 UTC
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.
Comment 5 LRN 2014-08-05 06:44:47 UTC
Attachment 282000 [details] pushed as 14f2376 - Change W32 console detection to look at the window, not stdout