fix: wait for completed evidence before forced cleanup
This commit is contained in:
@@ -130,14 +130,23 @@ internal static class PilotCli
|
|||||||
if (!config.ForceAfterEvidence) { await exit; gracefulExit = true; }
|
if (!config.ForceAfterEvidence) { await exit; gracefulExit = true; }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var timeout = Task.Delay(TimeSpan.FromSeconds(Math.Clamp(config.GracefulExitTimeoutSeconds, 1, 120)));
|
// The graceful-exit timeout is deliberately measured only after
|
||||||
if (await Task.WhenAny(exit, timeout) == exit) gracefulExit = true;
|
// terminal evidence is durable. Killing an active AutoCAD
|
||||||
|
// command before that boundary would turn ForceAfterEvidence
|
||||||
|
// into an unsafe general process killer.
|
||||||
|
while (!exit.IsCompleted && !HasCompletedEvidence(evidencePath))
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||||
|
if (exit.IsCompleted) gracefulExit = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!HasCompletedEvidence(evidencePath)) return new(true, false, false, false, false);
|
var timeout = Task.Delay(TimeSpan.FromSeconds(Math.Clamp(config.GracefulExitTimeoutSeconds, 1, 120)));
|
||||||
using var process = Process.GetProcessById(execution.ProcessId.Value);
|
if (await Task.WhenAny(exit, timeout) == exit) gracefulExit = true;
|
||||||
if (!process.HasExited) { process.Kill(entireProcessTree: true); forcedCleanup = true; }
|
else
|
||||||
await exit;
|
{
|
||||||
|
using var process = Process.GetProcessById(execution.ProcessId.Value);
|
||||||
|
if (!process.HasExited) { process.Kill(entireProcessTree: true); forcedCleanup = true; }
|
||||||
|
await exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user