You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating process groups is necessary to be able to send signals on Windows as they are sent to the whole group, you need to use CREATE_NEW_PROCESS_GROUP creation flag to isolate the signal from the parent process. POSIX systems have the same notion, however in unix-like systems one can use signals directly with processes.
This has been previously discussed in another issue in 2017 but it turned out that this change itself would not help the requesting team so it was dropped at that time. For the record, I am using proposals from that time.
Expose the creation flag via a Windows-only property.
namespace System.Diagnostics
{
public sealed partial class ProcessStartInfo
{
+ [SupportedOSPlatform("windows")]+ public bool CreateNewProcessGroup { get; set; }
}
}
Usage Examples
varstartInfo=newProcessStartInfo{FileName="my-program.exe",CreateNewProcessGroup=true,};varp=newProcess.Start(startInfo);// Do some work...GenerateConsoleCtrlEvent(0/* CTRL_C_EVENT */,(uint)process.Id)[DllImport("kernel32.dll")][return:MarshalAs(UnmanagedType.Bool)]publicstaticexternboolGenerateConsoleCtrlEvent(uintdwCtrlEvent,uintdwProcessGroupId);
[API Proposal]: Add API to gracefully terminate process #109432, diffrent property naming: EnableConsoleControlEvents. This name makes sense if CREATE_NEW_PROCESS_GROUP has no other reason to be used for, outside of signal isolation, I'm unaware of more scenarios where this is useful but that can change in the future.
Background and Motivation
Edited by @jozkee
Creating process groups is necessary to be able to send signals on Windows as they are sent to the whole group, you need to use
CREATE_NEW_PROCESS_GROUPcreation flag to isolate the signal from the parent process. POSIX systems have the same notion, however in unix-like systems one can use signals directly with processes.This has been previously discussed in another issue in 2017 but it turned out that this change itself would not help the requesting team so it was dropped at that time. For the record, I am using proposals from that time.
#20734
Proposed API
Expose the creation flag via a Windows-only property.
namespace System.Diagnostics { public sealed partial class ProcessStartInfo { + [SupportedOSPlatform("windows")] + public bool CreateNewProcessGroup { get; set; } } }Usage Examples
Alternative Designs
[API Proposal]:
ProcessStartInfo.CreationFlags(for Windows only) #71515 was considered but I've opted for this proposal instead as we do have concrete scenarios for it.[API Proposal]: Add API to gracefully terminate process #109432, diffrent property naming:
EnableConsoleControlEvents. This name makes sense if CREATE_NEW_PROCESS_GROUP has no other reason to be used for, outside of signal isolation, I'm unaware of more scenarios where this is useful but that can change in the future.Risks
None