From 4993779213393857d330ea2ae9f764ef5754997e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sun, 6 Oct 2024 12:38:08 +0200 Subject: [PATCH] buildtask: fix hang on large output Where the pipe buffer fills up and we get stuck in wait(), when we should have been consuming the buffer first. --- src/projects/buildtask.vala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/projects/buildtask.vala b/src/projects/buildtask.vala index 2b498294..aaf06b5e 100644 --- a/src/projects/buildtask.vala +++ b/src/projects/buildtask.vala @@ -274,6 +274,8 @@ class Vls.BuildTask : BuildTarget { } Subprocess process = launcher.spawnv (arguments); + Bytes stdout; + process.communicate (null, cancellable, out stdout, null); process.wait (cancellable); if (cancellable.is_cancelled ()) { process.force_exit (); @@ -297,11 +299,7 @@ class Vls.BuildTask : BuildTarget { if (output.size == 1 && !output[0].query_exists (cancellable)) { // write contents of stdout to the output file if it was not created var output_file = output[0]; - var process_output_istream = process.get_stdout_pipe (); - if (process_output_istream != null) { - var outfile_ostream = output_file.replace (null, false, FileCreateFlags.NONE, cancellable); - outfile_ostream.splice (process_output_istream, OutputStreamSpliceFlags.NONE, cancellable); - } + output_file.replace_contents (stdout.get_data (), null, false, FileCreateFlags.NONE, null, cancellable); } // update the file metadata cache foreach (var file in output)