gsubprocess: fix communicate() with empty buffers
authorRyan Lortie <desrt@desrt.ca>
Mon, 3 Mar 2014 02:01:12 +0000 (21:01 -0500)
committerRyan Lortie <desrt@desrt.ca>
Tue, 4 Mar 2014 02:26:24 +0000 (21:26 -0500)
commit9f71965becd919a736cb57bbd3501b22e6341fa7
tree648303f0c209f8edbe9fa3242da800512feb7aa2
parentde142c0c5ad9a35e704f1fc9eeeaed3684a30adb
gsubprocess: fix communicate() with empty buffers

On the splice for stdout or stderr completing, GSubprocess calls
_slice_finish() to collect the result.

We assume that a zero return value here means failure, but in fact this
function returns a gssize -- the number of bytes transferred, or -1 for
an error.

This causes GSubprocess to mistakenly think that it has an error when it
actually just has an empty buffer (as would be the case when collecting
stderr from a successful command).

Check for -1 instead of FALSE to detect the error.

https://bugzilla.gnome.org/show_bug.cgi?id=724916
gio/gsubprocess.c