Skip to content

Commit ddc826c

Browse files
committed
Merged PR 732965: Kill active ptracerunners on SandboxedProcess.KillAsync
Related work items: #2075989
1 parent ab545d0 commit ddc826c

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Diff for: Public/Src/Engine/Processes/SandboxedProcessUnix.cs

+15-5
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ protected override async Task KillAsyncInternal(bool dumpProcessTree)
429429
{
430430
// surviving child processes may only be set when the process is explicitly killed
431431
m_survivingChildProcesses = NullIfEmpty(CoalesceProcesses(GetCurrentlyActiveChildProcesses()));
432+
// Before notifying that the root process has exited, kill all ptracerunners to avoid receiving access reports after the communication pipe is closed.
433+
KillActivePTraceRunners();
432434
await base.KillAsyncInternal(dumpProcessTree);
433435
KillAllChildProcesses();
434436
SandboxConnection.NotifyRootProcessExited(PipId, this);
@@ -499,11 +501,7 @@ public override void Dispose()
499501

500502
// If ptrace runners have not finished yet, then do that now
501503
// Completing the task below will make us kill any leftover PTraceRunner processes
502-
m_ptraceRunnersCancellation.SetResult(true);
503-
foreach (var runner in TaskUtilities.SafeWhenAll(m_ptraceRunners.ToArray()).GetAwaiter().GetResult())
504-
{
505-
runner.Dispose();
506-
}
504+
KillActivePTraceRunners();
507505

508506
base.Dispose();
509507
}
@@ -1130,5 +1128,17 @@ async Task<AsyncProcessExecutor> runnerTask(AsyncProcessExecutor runner)
11301128
return runner;
11311129
}
11321130
}
1131+
1132+
private void KillActivePTraceRunners()
1133+
{
1134+
var ptraceRunners = m_ptraceRunners.ToArray();
1135+
m_ptraceRunners.Clear();
1136+
1137+
m_ptraceRunnersCancellation.TrySetResult(true);
1138+
foreach (var runner in TaskUtilities.SafeWhenAll(ptraceRunners).GetAwaiter().GetResult())
1139+
{
1140+
runner.Dispose();
1141+
}
1142+
}
11331143
}
11341144
}

0 commit comments

Comments
 (0)