Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Concurrent Windows stops can escalate descendant cleanup before root shutdown completes

Open
#287 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
backend

Research direction

Start with pkg/process/os_executor_windows.go and the shared tree-stop logic in pkg/process/os_executor.go, then read the existing Windows concurrent-stop test. Reproduce or extend coverage to distinguish native root exit from stdio-drain completion, including graceful and forced roots and descendant-held pipes. Done means the test establishes the intended descendant-escalation ordering while preserving stop ownership and bounded cancellation.

Written by the indexing model from the issue text.

Description

Summary

Follow-up to PR #278, reviewed at c49750ffc674334831dd2b00ac807987fd2432d4. This is not a blocker for that PR; improving the sequencing is deferred because the practical impact is narrow and a safe change must preserve the separation between process exit and output draining.

Current behavior

In pkg/process/os_executor_windows.go:113–120, a caller that does not own stopping waits for descendants, but returns immediately for the root (optWaitForStdio is set):

if !shouldStopProcess && (opts&optIsResponsibleForStopping) == 0 {
	if (opts & optWaitForStdio) == 0 {
		// Another stop owns signaling, but descendants must still be confirmed exited.
		waitErr := waitForTrackedProcessExit(ctx, handle.Pid, ws, 0)
		return singleProcessStopResult{waitEndedCh: waitEndedCh}, waitErr
	}
	return singleProcessStopResult{waitEndedCh: waitEndedCh}, nil
}

The shared tree-stop implementation uses the returned result to decide whether to begin graceful descendant cleanup:

forceDescendants := rootResult.forceKillUsed || rootStopErr != nil || graceCtx.Err() != nil

if len(tree) > 0 && !forceDescendants {
	// Begin descendant cleanup under the graceful context.
}

See pkg/process/os_executor.go:715–738. Because the joining root call returns no error and no force-kill indication, it can begin descendant cleanup while the owning caller is still waiting for the root to shut down.

For descendants whose console-event receipt is unknown, Windows normally allows a six-second passive wait before force termination. An overlapping caller can therefore start that wait early and terminate descendants while the root is still within its own 15-second graceful window. Explicit stopping overlapping process-context cancellation is one possible entry point.

Impact and confidence

The practical concern is interrupted coordinated shutdown: the root may still be arranging child shutdown when the joining caller force-kills those children, potentially cutting off their cleanup or final output. The joining caller can also time out waiting for the root while the owning stop continues.

This is not immediate force termination, and it does not directly shorten the root owner's graceful wait. This particular ownership path requires overlapping stops on the same executor. Identity validation and final exit confirmation remain in place; no wrong-process termination, false successful cleanup, or process leak has been demonstrated from this behavior.

The sequencing was verified through code inspection, not a local Windows runtime reproduction. The Windows concurrent test deliberately starts descendant stopping before releasing its gated root, so the behavior is accommodated by existing coverage rather than being entirely untested.

Follow-up direction

Determine whether concurrent Windows stops should enforce the shared root-first contract, and implement any change without waiting for output draining before descendant cleanup. A simple copy of the Unix non-owner wait is insufficient as a complete proposal: cmd.Wait() can remain blocked after root exit because descendants retain stdout/stderr pipes. The historical tree-stop design intentionally defers that completion until after descendant cleanup.

Use existing identity-aware process-exit inspection where appropriate, preserve bounded cancellation and stop ownership, and propagate the owner's force-kill outcome if needed. Cover graceful and forced roots, overlapping explicit/cancellation cleanup, and descendant-held output pipes. The regression test should distinguish native root exit from stdio-drain completion and explicitly establish the intended descendant-escalation ordering.

Dominant language
Go
Stars
191
Forks
26
Avg merge
1d 21h
Merged PRs (30d)
23

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/dcp

All issues in microsoft/dcp

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.