gsubprocess: Fix up communicate
authorColin Walters <walters@verbum.org>
Mon, 14 Oct 2013 23:12:22 +0000 (00:12 +0100)
committerRyan Lortie <desrt@desrt.ca>
Thu, 17 Oct 2013 18:32:44 +0000 (14:32 -0400)
commit0e1a3ee3450d1a091234292fde6109bf3c778bab
tree4aaf2ca6969b3951e2cfaf9dbc811a1520ff801d
parent5b48dc40cc13567d276883ee826fe9e78bc7f46a
gsubprocess: Fix up communicate

We weren't closing the streams after we were done reading or writing,
which is kind of essential.  The easy way to fix this is to just use
g_output_stream_splice() to a GMemoryOutputStream rather than
hand-rolling it.  This results in a substantial reduction of code
complexity.

A second serious issue is that we were marking the task as complete when
the process exits, but that's racy - there could still be data to read
from stdout.  Fix this by just refcounting outstanding operations.

This code, not surprisingly, looks a lot like the "multi" test.

Next, because processes output binary data, I'd be forced to annotate
the char*/length pairs as (array) (element-type uint8).  But rather than
doing that, it's *far* simpler to just use GBytes.

We need a version of this that actually validates as UTF-8, that will be
in the next patch.
gio/gsubprocess.c
gio/gsubprocess.h
gio/gsubprocesslauncher.c
gio/gsubprocesslauncher.h
gio/tests/gsubprocess.c