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



We have a helper that does questionable things during the spawning
process on Win32. This second helper is likely to be what's broken
under MSYS2.

See https://git.gnome.org/browse/glib/tree/glib/gspawn-win32.c#n22

On Mon, Sep 28, 2015 at 12:33 AM, Gang Chen <gang chen cn gmail com> wrote:
Yes, I suspect MSYS2 or bash does something special because other console
applications work well. I wrote a program using the GLib spawn function and
GIOChannel, and observed the same behavior. The read function got a G_IO_HUP
signal without any data read, when bash exited.

2015-09-28 13:27 GMT+08:00 LRN <lrn1986 gmail com>:

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

_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list



_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list




-- 
  Jasper


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