Skip to content

[API Proposal]: Process constructor from SafeProcessHandle #71595

@NN---

Description

@NN---

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

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions