Kieli

ProcessStartInfo.InheritedHandles Property

Definition

Gets or sets a list of handles to be inherited by the child process.

public:
 property System::Collections::Generic::IList<System::Runtime::InteropServices::SafeHandle ^> ^ InheritedHandles { System::Collections::Generic::IList<System::Runtime::InteropServices::SafeHandle ^> ^ get(); void set(System::Collections::Generic::IList<System::Runtime::InteropServices::SafeHandle ^> ^ value); };
public System.Collections.Generic.IList<System.Runtime.InteropServices.SafeHandle>? InheritedHandles { get; set; }
member this.InheritedHandles : System.Collections.Generic.IList<System.Runtime.InteropServices.SafeHandle> with get, set
Public Property InheritedHandles As IList(Of SafeHandle)

Property Value

A list of SafeHandle objects to be explicitly inherited by the child process, or null to use the default handle inheritance behavior.

Remarks

When this property is not null, handle inheritance is restricted to the standard handles and the handles from this list. If the list is empty, only the standard handles are inherited.

Only SafeFileHandle and SafePipeHandle are supported in this list.

Setting this property on Unix systems that do not have native support for controlling handle inheritance can severely degrade process start performance.

Handles in this list should not have inheritance enabled beforehand. If they do, they could be unintentionally inherited by other processes started concurrently with different APIs, which might lead to security or resource management issues.

Two concurrent process starts that pass the same handle in InheritedHandles are not supported. On Windows, the implementation temporarily modifies each handle's inheritance flags. Those modifications aren't thread-safe across concurrent starts sharing the same handle.

This API can't be used together with UseShellExecute set to true or when specifying a user name via the UserName property.

On Windows, the implementation temporarily enables inheritance on each handle in this list by modifying the handle's flags using SetHandleInformation. After the child process is created, inheritance is unconditionally disabled on these handles to prevent them from being inherited by other processes started with different APIs. The handles themselves aren't duplicated; they're made inheritable and passed to the child process.

On Unix, the implementation modifies each file descriptor in the child process by removing the FD_CLOEXEC flag. The modification occurs after the fork and before the exec, so it doesn't affect the parent process.

Applies to