work around process wait race condition
MODIFY
src/TextCopy/BashRunner.cs
src/TextCopy/BashRunner.cs
@@ -27,7 +27,7 @@ static class BashRunner
process.BeginOutputReadLine();
process.ErrorDataReceived += (sender, args) => { errorBuilder.AppendLine(args.Data); };
process.BeginErrorReadLine();
- if (!process.WaitForExit(500))
+ if (!process.DoubleWaitForExit())
{
var timeoutError = $@"Process timed out. Command line: bash {arguments}.
Output: {outputBuilder}
@@ -44,5 +44,16 @@ Output: {outputBuilder}
Error: {errorBuilder}";
throw new Exception(error);
}
+
+ //To work around https://github.com/dotnet/runtime/issues/27128
+ static bool DoubleWaitForExit(this Process process)
+ {
+ var result = process.WaitForExit(500);
+ if (result)
+ {
+ process.WaitForExit();
+ }
+ return result;
+ }
}
#endif
\ No newline at end of file

work around process wait race condition (#137)