From f27a12074d4498ed3593cc07b4d849a2229ea217 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 18:58:34 +0000 Subject: [PATCH 1/2] Initial plan From 9c79787b59f83a0f0a6a2646a77747ef37afc08f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 19:03:19 +0000 Subject: [PATCH 2/2] Fix ProcessGroup example: use CTRL_BREAK_EVENT instead of CTRL_C_EVENT 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> --- .../dotnet-10/snippets/csharp/ProcessGroup.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/core/whats-new/dotnet-10/snippets/csharp/ProcessGroup.cs b/docs/core/whats-new/dotnet-10/snippets/csharp/ProcessGroup.cs index fce205adc4386..43b198f7f5a19 100644 --- a/docs/core/whats-new/dotnet-10/snippets/csharp/ProcessGroup.cs +++ b/docs/core/whats-new/dotnet-10/snippets/csharp/ProcessGroup.cs @@ -21,26 +21,27 @@ static void Main(string[] args) using Process process = Process.Start(psi)!; Thread.Sleep(5_000); - GenerateConsoleCtrlEvent(CTRL_C_EVENT, (uint)process.Id); + GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, (uint)process.Id); process.WaitForExit(); Console.WriteLine("Child process terminated gracefully, continue with the parent process logic if needed."); } else { - // If you need to send a CTRL+C, the child process needs to re-enable CTRL+C handling, if you own the code, you can call SetConsoleCtrlHandler(NULL, FALSE). + // CREATE_NEW_PROCESS_GROUP disables CTRL+C handling in the new process group. + // CTRL+BREAK is not affected, so you don't need to re-enable it with SetConsoleCtrlHandler. + // If you use CTRL+C instead, re-enable handling by calling SetConsoleCtrlHandler(NULL, FALSE). // see https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw#remarks - SetConsoleCtrlHandler((IntPtr)null, false); Console.WriteLine("Greetings from the child process! I need to be gracefully terminated, send me a signal!"); bool stop = false; - var registration = PosixSignalRegistration.Create(PosixSignal.SIGINT, ctx => + var registration = PosixSignalRegistration.Create(PosixSignal.SIGQUIT, ctx => { stop = true; ctx.Cancel = true; - Console.WriteLine("Received CTRL+C, stopping..."); + Console.WriteLine("Received CTRL+BREAK, stopping..."); }); StreamWriter sw = File.AppendText("log.txt");