Skip to content

Commit

Permalink
Retry installer Process.Start if ETXTBSY
Browse files Browse the repository at this point in the history
  • Loading branch information
agocke committed Sep 29, 2021
1 parent 8e4c996 commit 866aaeb
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/installer/tests/TestUtils/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -120,7 +121,7 @@ private static bool ShouldUseCmd(string executable)
}
else
{
// Search the path to see if we can find it
// Search the path to see if we can find it
foreach (var path in System.Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator))
{
var candidate = Path.Combine(path, executable + ".exe");
Expand Down Expand Up @@ -196,7 +197,20 @@ public Command Start()

ReportExecBegin();

Process.Start();
// Retry if we hit ETXTBSY due to Linux race
// https://github.com/dotnet/runtime/issues/58964
for (int i = 0; i < 3; i++)
{
try
{
Process.Start();
break;
}
catch (Win32Exception e) when (e.Message.Contains("Text file busy"))
{
Thread.Sleep(10);
}
}

if (Process.StartInfo.RedirectStandardOutput)
{
Expand Down

0 comments on commit 866aaeb

Please sign in to comment.