Skip to content

Fix Windows process group example: CTRL_BREAK_EVENT, not CTRL_C_EVENT#53564

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-launch-windows-process-signals
Open

Fix Windows process group example: CTRL_BREAK_EVENT, not CTRL_C_EVENT#53564
Copilot wants to merge 2 commits intomainfrom
copilot/fix-launch-windows-process-signals

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

GenerateConsoleCtrlEvent with CTRL_C_EVENT silently succeeds but delivers no signal when the target process group ID is non-zero. The example was broken by design.

Changes

  • Parent: CTRL_C_EVENTCTRL_BREAK_EVENT — the only valid choice when targeting a non-default process group
  • Child signal handler: PosixSignal.SIGINTPosixSignal.SIGQUIT — on Windows, SIGQUIT maps to CTRL_BREAK_EVENT; SIGINT maps to CTRL_C_EVENT
  • Child setup: Removed SetConsoleCtrlHandler(NULL, FALSE) call — CREATE_NEW_PROCESS_GROUP disables CTRL+C, not CTRL+BREAK, so re-enabling isn't needed here; updated comment to explain the distinction and note when the call is required
// Before (broken — silently does nothing for non-zero process group IDs)
GenerateConsoleCtrlEvent(CTRL_C_EVENT, (uint)process.Id);

// After
GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, (uint)process.Id);

…T for process groups

Agent-Logs-Url: https://github.com/dotnet/docs/sessions/f36bbc2c-5f0f-4b18-a5de-6f801890df6d

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix signal used in Launch Windows processes example Fix Windows process group example: CTRL_BREAK_EVENT, not CTRL_C_EVENT May 5, 2026
Copilot AI requested a review from gewarren May 5, 2026 19:04
@gewarren gewarren marked this pull request as ready for review May 5, 2026 19:10
@gewarren gewarren requested a review from a team as a code owner May 5, 2026 19:10
Copilot AI review requested due to automatic review settings May 5, 2026 19:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 fixes the .NET 10 “Windows process management” snippet so it can actually signal a child process launched in a non-default process group. It updates the parent to use CTRL_BREAK_EVENT (instead of CTRL_C_EVENT), aligns the child’s managed signal handler with that event, and removes an unnecessary SetConsoleCtrlHandler call while clarifying the behavior in comments.

Changes:

  • Send CTRL_BREAK_EVENT from the parent when targeting the child process group.
  • Handle CTRL+BREAK in the child via PosixSignal.SIGQUIT and update the log message accordingly.
  • Remove the SetConsoleCtrlHandler(NULL, FALSE) call and replace it with a clearer explanation of when it’s needed.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Launch Windows processes in new process group example uses the wrong signal (CTRL_C instead of CTRL_BREAK)

3 participants