[Geany-devel] win32_spawn hangs if child process writes more than 4kb to stdout

Josh Pschorr josh at xxxxx
Fri Jul 15 21:46:25 UTC 2011


Hi,

I ran into an issue using Geany on Windows where-in using either the build
or compile
commands to kick off a custom script caused Geany to hang for about a
minute, after
which it returned and the compiler log showed only a fraction of the output
it should.

After tracking this down, it seems that on Windows, a custom spawn function
is used
in *build_spawn_cmd* and rather than *
g_spawn_async_with_pipes, utils_spawn_sync*
which ends up calling *win32_spawn*.

*win32_spawn* would set up pipes for stdout and stderr (using default buffer
size),
kick off the a child process, wait for it finish, and finally dump the
stdout/stderr pipes
to a temp file and then read that into memory. if the process didn't exit
after a minute,
it was forcefully killed.

The problem seems to be that pipes are only 4kb buffered by default, so any
process
needing to write more than this would block while writing to stdout and
Geany would
kill it, as it wasn't reading the pipes until after the process exited.

The attached patch fixes this such that the pipes are read and dumped to the
temp
file continuously as the child process runs.  Now the child process will be
forcibly killed
only if it doesn't write to one of its pipes for at least 30 seconds.




Out of curiosity, why isn't *g_spawn_async_with_pipes* used on Windows?  It
seems to
work with some degree of success for the grep command (as used by *
search_find_in_files*),
albeit without completion status reporting.


Regards,
Josh Pschorr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/devel/attachments/20110715/356bb78f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-win32_spawn-for-more-than-4kb.patch
Type: application/octet-stream
Size: 6731 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20110715/356bb78f/attachment.obj>


More information about the Devel mailing list