diff options
author | Руслан Ижбулатов <lrn1986@gmail.com> | 2017-11-26 18:27:51 +0000 |
---|---|---|
committer | Руслан Ижбулатов <lrn1986@gmail.com> | 2018-06-13 19:20:01 +0000 |
commit | cb0cd2a815cbce274189056451b7468b33c8f631 (patch) | |
tree | 7eafd097258efd20b84b3b16bbe2a648587cb531 /glib/glib-init.c | |
parent | c26558c1b1391f32f208a48a47fa7a714f2b7529 (diff) | |
download | glib-lrn/attachconsole.tar.gz |
W32: add std stream redirection envvar optionslrn/attachconsole
This commit adds two W32-only environmental variable checks:
* G_WIN32_ALLOC_CONSOLE, if set to 1, will force glib to create
a new console if the process has no console by itself.
This option is for GUI apps that are launched from GUI
processes, in which case there's no console anywhere near them.
* G_WIN32_ATTACH_CONSOLE, if set to a comma-separated list of
standard stream names (stdint, stdout, stderr), will reopen
a given std stream and tie it to the console (using existing console
or parent console).
This works either with the other option (to create a console),
or if the app is launched from a console process (often the
case for developers).
The redirection is done with freopen(), dup() and dup2().
If everything goes well, C file descriptors 0, 1 or 2 will
be bound to stdin, stdout and stderr respectively (only for
streams listed in the envrionmental variable), and so will
be stdio streams by the same names.
With these it's possible to see the output of g_log*() functions
when running GTK4 applications, which are linked as GUI applications,
and thus do not get a console by default.
https://bugzilla.gnome.org/show_bug.cgi?id=790857
Fixes issue #1304
Diffstat (limited to 'glib/glib-init.c')
-rw-r--r-- | glib/glib-init.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/glib/glib-init.c b/glib/glib-init.c index 2e229667f..6cb4e4a0d 100644 --- a/glib/glib-init.c +++ b/glib/glib-init.c @@ -292,6 +292,8 @@ DllMain (HINSTANCE hinstDLL, g_thread_win32_init (); #endif glib_init (); + /* must go after glib_init */ + g_console_win32_init (); break; case DLL_THREAD_DETACH: |