-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Add StandardInput/Output/Error SafeFileHandle properties and LeaveHandlesOpen to ProcessStartInfo #125848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: copilot/refactor-startcore-method-arguments
Are you sure you want to change the base?
Add StandardInput/Output/Error SafeFileHandle properties and LeaveHandlesOpen to ProcessStartInfo #125848
Changes from all commits
419d7ab
18995de
d40cf18
60844f3
c8b8723
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| using System.ComponentModel; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Text; | ||
| using Microsoft.Win32.SafeHandles; | ||
|
|
||
| namespace System.Diagnostics | ||
| { | ||
|
|
@@ -117,6 +118,89 @@ public string Arguments | |
| public bool RedirectStandardOutput { get; set; } | ||
| public bool RedirectStandardError { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a <see cref="SafeFileHandle"/> that will be used as the standard input of the child process. | ||
| /// When set, the handle is passed directly to the child process and <see cref="RedirectStandardInput"/> must be <see langword="false"/>. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// The handle does not need to be inheritable; the runtime will make it inheritable as needed. | ||
| /// Use <see cref="SafeFileHandle.CreateAnonymousPipe"/> to create a pair of connected pipe handles, | ||
| /// <see cref="IO.File.OpenHandle"/> to open a file handle, | ||
| /// <see cref="IO.File.OpenNullHandle"/> to discard input, | ||
| /// or <see cref="Console.OpenStandardInputHandle"/> to inherit the parent's standard input. | ||
| /// </para> | ||
| /// <para> | ||
| /// By default, <see cref="Process.Start()"/> will close this handle after starting the child process. | ||
| /// Set <see cref="LeaveHandlesOpen"/> to <see langword="true"/> to keep the handle open. | ||
| /// </para> | ||
| /// <para> | ||
| /// This property cannot be used together with <see cref="RedirectStandardInput"/> | ||
| /// and requires <see cref="UseShellExecute"/> to be <see langword="false"/>. | ||
| /// </para> | ||
| /// </remarks> | ||
| /// <value>A <see cref="SafeFileHandle"/> to use as the standard input handle of the child process, or <see langword="null"/> to use the default behavior.</value> | ||
| public SafeFileHandle? StandardInput { get; set; } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there any requirements around its inheritability that should be called out in the docs? Maybe add some XML comments remarks around when this would be used, what APIs it might typically used in conjunction with, etc.?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
|
|
||
| /// <summary> | ||
| /// Gets or sets a <see cref="SafeFileHandle"/> that will be used as the standard output of the child process. | ||
| /// When set, the handle is passed directly to the child process and <see cref="RedirectStandardOutput"/> must be <see langword="false"/>. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// The handle does not need to be inheritable; the runtime will make it inheritable as needed. | ||
| /// Use <see cref="SafeFileHandle.CreateAnonymousPipe"/> to create a pair of connected pipe handles, | ||
| /// <see cref="IO.File.OpenHandle"/> to open a file handle, | ||
| /// <see cref="IO.File.OpenNullHandle"/> to discard output, | ||
| /// or <see cref="Console.OpenStandardOutputHandle"/> to inherit the parent's standard output. | ||
| /// </para> | ||
| /// <para> | ||
| /// By default, <see cref="Process.Start()"/> will close this handle after starting the child process. | ||
| /// Set <see cref="LeaveHandlesOpen"/> to <see langword="true"/> to keep the handle open. | ||
| /// </para> | ||
| /// <para> | ||
| /// This property cannot be used together with <see cref="RedirectStandardOutput"/> | ||
| /// and requires <see cref="UseShellExecute"/> to be <see langword="false"/>. | ||
| /// </para> | ||
| /// </remarks> | ||
| /// <value>A <see cref="SafeFileHandle"/> to use as the standard output handle of the child process, or <see langword="null"/> to use the default behavior.</value> | ||
| public SafeFileHandle? StandardOutput { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a <see cref="SafeFileHandle"/> that will be used as the standard error of the child process. | ||
| /// When set, the handle is passed directly to the child process and <see cref="RedirectStandardError"/> must be <see langword="false"/>. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// The handle does not need to be inheritable; the runtime will make it inheritable as needed. | ||
| /// Use <see cref="SafeFileHandle.CreateAnonymousPipe"/> to create a pair of connected pipe handles, | ||
| /// <see cref="IO.File.OpenHandle"/> to open a file handle, | ||
| /// <see cref="IO.File.OpenNullHandle"/> to discard error output, | ||
| /// or <see cref="Console.OpenStandardErrorHandle"/> to inherit the parent's standard error. | ||
| /// </para> | ||
| /// <para> | ||
| /// By default, <see cref="Process.Start()"/> will close this handle after starting the child process. | ||
| /// Set <see cref="LeaveHandlesOpen"/> to <see langword="true"/> to keep the handle open. | ||
| /// </para> | ||
| /// <para> | ||
| /// This property cannot be used together with <see cref="RedirectStandardError"/> | ||
| /// and requires <see cref="UseShellExecute"/> to be <see langword="false"/>. | ||
| /// </para> | ||
| /// </remarks> | ||
| /// <value>A <see cref="SafeFileHandle"/> to use as the standard error handle of the child process, or <see langword="null"/> to use the default behavior.</value> | ||
| public SafeFileHandle? StandardError { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a value indicating whether the <see cref="StandardInput"/>, <see cref="StandardOutput"/>, | ||
| /// and <see cref="StandardError"/> handles should be left open after the process is started. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// When <see langword="false"/> (the default), the handles are closed by <see cref="Process.Start()"/> | ||
| /// after starting the child process. When <see langword="true"/>, the caller is responsible for closing the handles. | ||
| /// </remarks> | ||
| /// <value><see langword="true"/> to leave the handles open; <see langword="false"/> to close them after the process starts. The default is <see langword="false"/>.</value> | ||
| public bool LeaveHandlesOpen { get; set; } | ||
|
|
||
| public Encoding? StandardInputEncoding { get; set; } | ||
|
|
||
| public Encoding? StandardErrorEncoding { get; set; } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.