Skip to content

Follow-up: Review the process-exit fix in #16191 - #16372

Draft
Jakub Jareš (nohwnd) wants to merge 1 commit into
microsoft:mainfrom
nohwnd:nohwnd-fix-process-exit-marker-race
Draft

Follow-up: Review the process-exit fix in #16191#16372
Jakub Jareš (nohwnd) wants to merge 1 commit into
microsoft:mainfrom
nohwnd:nohwnd-fix-process-exit-marker-race

Conversation

@nohwnd

Copy link
Copy Markdown
Member

Implemented and committed the process-exit marker race fix for microsoft/vstest#16191.

Coordinated Kill and marker publication under one lock, publishing the marker only after Kill succeeds. Added a regression test for a natural exit winning the race.

Evidence:

  • .\build.cmd -c Release -project test\vstest.console.UnitTests\vstest.console.UnitTests.csproj succeeded
  • ProcessHelperTests passed 7/7 on net11.0 and 7/7 on net481
  • Working tree is clean

🤖

Wait asynchronously for redirected stderr after process exit, keep deliberate aborts on the short drain budget, and publish the deliberate-termination marker only after Kill succeeds while coordinating marker reads with that outcome. Add coverage for a natural exit winning the HasExited/Kill race.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

🤖
Copilot AI lite review requested due to automatic review settings August 17, 2026 12:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR follows up on the process-exit marker race fix from #16191 by coordinating deliberate process termination with stderr-drain budget selection, so naturally-exited processes aren’t misclassified as “aborted” and crash stderr has enough time to drain.

Changes:

  • Replace the stderr “EOF reached” signal from ManualResetEventSlim to an awaitable TaskCompletionSource, and switch the drain wait to an async, bounded implementation.
  • Track deliberately terminated processes and coordinate “Kill + marker publication” under a single lock so the exit handler chooses the correct stderr-drain timeout.
  • Add/extend unit tests covering late EOF delivery, fast paths, bounded waits, timeout selection, and the “Kill loses the race” regression scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/vstest.console.UnitTests/ProcessHelperTests.cs Updates and adds unit tests for async stderr draining and deliberate-termination race behavior.
src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs Implements async bounded stderr-drain waiting and coordinated deliberate-termination marking to select correct drain budgets.
Suppressed comments (1)

test/vstest.console.UnitTests/ProcessHelperTests.cs:90

  • The upper-bound assertion here doesn’t validate that the wait is actually bounded by the requested timeout (BudgetMs = 500). As written, a regression that waits for several seconds (but still < 5s) would pass. Tie the upper bound to BudgetMs (with a generous multiplier/slack) so the test fails if the implementation ignores the provided timeout.
        Assert.IsLessThan(
            5000L,
            stopwatch.ElapsedMilliseconds,
            $"The wait must be bounded so it cannot hang (took {stopwatch.ElapsedMilliseconds} ms).");

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants