Skip to content

Allow for Job escape when using KillOnParentExit - #130032

Merged
adamsitnik merged 5 commits into
mainfrom
copilot/use-job-object-limit-breakaway-ok
Jun 30, 2026
Merged

Allow for Job escape when using KillOnParentExit#130032
adamsitnik merged 5 commits into
mainfrom
copilot/use-job-object-limit-breakaway-ok

Conversation

CopilotAI commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Pull request created by AI Agent

…test
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>

@adamsitnikadamsitnik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot apply my suggestion

…ocess
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
CopilotAI requested review from Copilot and removed request for CopilotJune 30, 2026 13:55

CopilotAI commented Jun 30, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot apply my suggestion

Applied your suggestion in commit e3d9df3. Removed KillOnParentExit and RedirectStandardOutput from the grandchild, and changed the lambda to parameterless since the argument is no longer needed.

CopilotAI requested a review from adamsitnikJune 30, 2026 13:56
@adamsitnik
adamsitnik marked this pull request as ready for review June 30, 2026 13:56
CopilotAI review requested due to automatic review settings June 30, 2026 13:56

@adamsitnikadamsitnik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM assuming the CI passes (some CI runners impose no Job escape rule). If this is going to be the case here, we are going to limit the new test to local runs only.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.

@adamsitnikadamsitnik changed the title Implementing JOB_OBJECT_LIMIT_BREAKAWAY_OK for process managementAllow for Job escape when using KillOnParentExitJun 30, 2026

CopilotAI 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 updates the Windows KillOnParentExit Job Object configuration in System.Diagnostics.Process to allow child processes to create breakaway descendants, and adds a Windows test exercising CREATE_BREAKAWAY_FROM_JOB.

Changes:

  • Enable JOB_OBJECT_LIMIT_BREAKAWAY_OK on the Job Object used for ProcessStartInfo.KillOnParentExit on Windows.
  • Add missing interop constants for JOB_OBJECT_LIMIT_BREAKAWAY_OK and CREATE_BREAKAWAY_FROM_JOB.
  • Add a Windows test that starts a “grandchild” process with CREATE_BREAKAWAY_FROM_JOB under both KillOnParentExit=true/false.

Reviewed changes

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

FileDescription
src/libraries/System.Diagnostics.Process/tests/ProcessHandlesTests.Windows.csAdds a test that creates a breakaway grandchild process under RemoteExecutor.
src/libraries/System.Diagnostics.Process/src/Microsoft/Win32/SafeHandles/SafeProcessHandle.Windows.csUpdates the KillOnParentExit Job Object limit flags to include breakaway support.
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.JobObjects.csAdds JOB_OBJECT_LIMIT_BREAKAWAY_OK interop constant.
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.csAdds CREATE_BREAKAWAY_FROM_JOB interop constant.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 30, 2026 14:12

CopilotAI 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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
CopilotAI review requested due to automatic review settings June 30, 2026 14:22
Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>

CopilotAI 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

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

@danegstadanegsta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Flags look correct; that should cover our needs perfectly to let us fork cleanup processes outside of the job object.

@adamsitnik
adamsitnik merged commit feffe53 into mainJun 30, 2026
84 of 87 checks passed
@adamsitnik
adamsitnik deleted the copilot/use-job-object-limit-breakaway-ok branch June 30, 2026 18:17
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
fixes#129709
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Aug 1, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add JOB_OBJECT_LIMIT_BREAKAWAY_OK to CreateKillOnParentExitJob for Windows KillOnParentExit support

4 participants

@adamsitnik@danegsta