From 75ea6203bd5ca7f896750abf48d75e5b27ad4520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Fri, 26 Feb 2021 15:26:24 -0800 Subject: [PATCH] Flush ProcessUtil buffer (#952) * Update ProcessUtil.cs * Update ProcessUtil.cs --- src/Microsoft.Tye.Core/ProcessUtil.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Microsoft.Tye.Core/ProcessUtil.cs b/src/Microsoft.Tye.Core/ProcessUtil.cs index 2fae79d7..ef77ec44 100644 --- a/src/Microsoft.Tye.Core/ProcessUtil.cs +++ b/src/Microsoft.Tye.Core/ProcessUtil.cs @@ -103,6 +103,10 @@ namespace Microsoft.Tye process.Exited += (_, e) => { + // Even though the Exited event has been raised, WaitForExit() must still be called to ensure the output buffers + // have been flushed before the process is considered completely done. + process.WaitForExit(); + if (throwOnError && process.ExitCode != 0) { processLifetimeTask.TrySetException(new InvalidOperationException($"Command {filename} {arguments} returned exit code {process.ExitCode}"));