[Geany-Devel] [geany/geany] a3664f: Fix spawning [synchronous] commands on Windows

Thomas Martitz thomas.martitz at student.htw-berlin.de
Sat Nov 17 19:04:39 UTC 2012


Am 16.11.2012 21:31, schrieb Dimitar Zhekov:
> On Thu, 15 Nov 2012 13:06:53 +0000
> Nick Treleaven <nick.treleaven at btinternet.com> wrote:
>
>>>> On 26/10/2012 17:44, Dimitar Zhekov wrote:
>>>>> I'm using Geany on win~1 recently, with gtk+2.16 and glib-2.22 (the
>>>>> minimum versions). g_spawn_async_with_pipes() works fine for me, from a
>>>>> plugin, for a console application, along with the helper.
>>>> So redirecting I/O works for stdout, stderr and it works for build
>>>> commands like gcc, make, grep, etc?
>>> It works between a console program and the plugin that spawned it, with
>>> {PeekNamedPipe() + read()} and {repeat write() on N ms} calls.
>> This confused me. Are you saying you use native Windows functions in
>> combination with g_spawn? I thought only g_io_add_watch could be used.
> g_spawn_async_with_pipes() returns libc/msvcrt fd-s. You can use them
> to create channels, or directly.
>
> Anonymous win~1 pipe fd-s are handled by giowin like regular fd-s
> (G_IO_WIN32_FILE_DESC), which causes problems, and I wanted a single
> g_source with the order of stdin/out/err operations order under my
> control. So calling read() and write() turned out to be easier. giowin
> uses them at the lowest level too.
>


FWIW, I recently fought with windows fd-s too, but I don't know if it 
helps in Geany's case. glib's poll() is broken for non-socket fd-s (i.e. 
broken stdout/stdin). There is a much better poll implementation for 
win32 available, at pulseaudio (contributed by me, based on gnulib's 
with some fixes). With that you could, in theory, monitor stdout of 
another process in a sensible fashion.

Best regards.


More information about the Devel mailing list