Background and motivation
There are plenty of ways to create a process where .NET does not support this or where there is already a process handle from native method.
Currently there is no possibility to create a .NET Process object from the SafeProcessHandle.
API Proposal
namespace System.Diagnostics;
public class Process
{
public Process(
SafeProcessHandle processHandle,
SafeFileHandle? standardInput = null,
SafeFileHandle? standardOutput = null,
SafeFileHandle? standardError = null,
ProcessStartInfo? startInfo = null)
}
API Usage
using SafeProcessHandle processHandle = Win32Api.CreateProcess(…);
Process process = new Process(processHandle);
Alternative Designs
Adding per platform different process creation options.
Such as #71515
Risks
There should be no risk.
We already have a precedent with Socket constructor from SafeSockegHandle.
A prototype was implemented in #128491
Background and motivation
There are plenty of ways to create a process where .NET does not support this or where there is already a process handle from native method.
Currently there is no possibility to create a .NET Process object from the SafeProcessHandle.
API Proposal
API Usage
Alternative Designs
Adding per platform different process creation options.
Such as #71515
Risks
There should be no risk.
We already have a precedent with Socket constructor from SafeSockegHandle.
A prototype was implemented in #128491