Re: Can't read stdout of bash with GSubprocess on MSYS2



On 28.09.2015 5:01, Gang Chen wrote:
Hi,
I'm writing a GTK+ application with MINGW-W64, which spawns a subprocess
running bash to execute some commands with GSubprocess and reads stdout of
bash (installed from MSYS2). I found that if compiled without "-mwindows"
compilation option the main process can read the stdout, while with
"-mwindows", the read function always returns 0 bytes read. If the main
process runs a normal console program, or like "mingw32/bin/gcc.exe", then
it can read stdout even if compiled with "-mwindows".

Might have something to do with what Cygwin/MSYS2 does to its stdout/stderr
handles on initialization (as opposed to normal W32 applications).

You could also try to write a pure-W32 API application that does this
(spawns different child processes with stdout/stderr redirected to pipes,
reads from the pipes; read g_win32_input_stream_* functions to see which
W32 API or C Runtime functions are used by glib to create pipes and read
from them) to diagnose the problem with Cygwin/MSYS2 without involving
glib. If you manage to do so and if the problem does affect non-glib-based
main process spawning bash (but not gcc), you can direct your question to
Cygwin and/or MSYS2 developers. If the problem only affects glib-based main
process, try to put a breakpoint on g_win32_input_stream_read() (assuming
you have debug info for glib) and see what it does, and how it works
differently depending on what kind of child process you are running.

-- 
O< ascii ribbon - stop html email! - www.asciiribbon.org

Attachment: 0x922360B0.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]