Skip to content

Commit 7cd5bce

Browse files
committed
Fix hang when a build task produces large output
Where the pipe buffer fills up and we get stuck in wait(), when we should have been consuming the buffer first.
1 parent 31cb511 commit 7cd5bce

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/projects/buildtask.vala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ class Vls.BuildTask : BuildTarget {
274274
}
275275

276276
Subprocess process = launcher.spawnv (arguments);
277+
Bytes stdout;
278+
process.communicate (null, cancellable, out stdout, null);
277279
process.wait (cancellable);
278280
if (cancellable.is_cancelled ()) {
279281
process.force_exit ();
@@ -297,11 +299,7 @@ class Vls.BuildTask : BuildTarget {
297299
if (output.size == 1 && !output[0].query_exists (cancellable)) {
298300
// write contents of stdout to the output file if it was not created
299301
var output_file = output[0];
300-
var process_output_istream = process.get_stdout_pipe ();
301-
if (process_output_istream != null) {
302-
var outfile_ostream = output_file.replace (null, false, FileCreateFlags.NONE, cancellable);
303-
outfile_ostream.splice (process_output_istream, OutputStreamSpliceFlags.NONE, cancellable);
304-
}
302+
output_file.replace_contents (stdout.get_data (), null, false, FileCreateFlags.NONE, null, cancellable);
305303
}
306304
// update the file metadata cache
307305
foreach (var file in output)

0 commit comments

Comments
 (0)