본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)5.8k · #14655

process-api-net11

하는 일

이 스킬은 .NET 11의 새 Process API를 써서 외부 프로그램을 실행하고, 출력을 캡처하고, 수명을 관리하는 방법을 설명합니다. 다른 프로그램을 시작하는 .NET 11 앱을 만드는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓.NET 11 앱이 외부 프로그램을 실행하고 출력을 캡처해야 할 때.
  • ✓부모 앱이 끝나면 자식 프로세스가 자동으로 닫혀야 할 때.
  • ✓분리된 프로세스를 시작하거나 자식이 상속하는 핸들을 조절해야 할 때.

스킬 링크

https://github.com/dotnet/skills/blob/main/plugins/dotnet11/skills/process-api-net11/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/dotnet/skills/blob/main/plugins/dotnet11/skills/process-api-net11/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 .NET 11 앱에서 명령줄 도구를 실행해 텍스트 출력을 캡처하고, 앱이 끝나면 그 도구도 닫히게 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트가 대기와 출력 캡처를 처리하는 새 .NET 11 프로세스 메서드를 쓰고, 요청한 수명 옵션을 설정합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Process API Improvements — .NET 11

New APIs added to System.Diagnostics.Process in .NET 11 simplify process management, eliminate boilerplate, and prevent common deadlock patterns when capturing output in .NET 11 or later applications.

When to Use

  • Running or orchestrating external processes in a .NET 11 (or later) project.
  • Needing to start a process, wait for it to exit, and capture its output/error streams without risking deadlocks (Process.RunAndCaptureText[Async]).
  • Wanting to ensure child processes are automatically terminated when the parent process exits (KillOnParentExit).
  • Requiring lightweight, low-overhead process creation via SafeProcessHandle on supported platforms.
  • Requiring fine-grained control over handle inheritance (InheritedHandles) or starting detached processes (StartDetached).

When Not to Use

  • The project targets .NET 10 or earlier — these APIs are not available before .NET 11.
  • The default Process.Start() is sufficient and does not require output capturing or advanced lifecycle rules.

Target Framework

<TargetFramework>net11.0</TargetFramework>

New APIs

Types

Before using the new convenience methods, note the following types. Use the framework types directly:

Type Kind Read-only properties
ProcessExitStatus Sealed class int ExitCode, bool Canceled, PosixSignal? Signal
ProcessTextOutput Sealed class ProcessExitStatus ExitStatus, string StandardOutput, string StandardError, int ProcessId
ProcessOutputLine Readonly struct string Content, bool StandardError

ProcessExitStatus describes the outcome of a completed process. Interpret ExitCode using the external command's contract; there is no universal Success property. ProcessTextOutput contains the exit status, captured output and error text, and process ID. ProcessOutputLine identifies one output line and whether it came from standard error.

High-Level Convenience APIs

Static Methods

The ProcessStartInfo overloads below require UseShellExecute = false, which is the default for .NET.

Process.Run / Process.RunAsync

Starts a process and waits for it to exit, returning the exit status. Does not capture standard output or error. Passing silent: true discards standard output and error by internally redirecting standard handles to the NUL device. On timeout or cancellation, the process is killed.

public static ProcessExitStatus Run(string fileName, IEnumerable<string>? arguments = null, bool silent = false, TimeSpan? timeout = null)
public static Task<ProcessExitStatus> RunAsync(string fileName, IEnumerable<string>? arguments = null, bool silent = false, CancellationToken cancellationToken = default)
public static ProcessExitStatus Run(ProcessStartInfo startInfo, TimeSpan? timeout = null)
public static Task<ProcessExitStatus> RunAsync(ProcessStartInfo startInfo, CancellationToken cancellationToken = default)
Process.RunAndCaptureText / Process.RunAndCaptureTextAsync

Starts a process, captures both standard output and error, and waits for it to exit. Extremely useful for avoiding deadlocks on stream redirection. On timeout or cancellation, the process is killed.

When using the ProcessStartInfo overloads, the caller is responsible for setting RedirectStandardOutput = true and RedirectStandardError = true on ProcessStartInfo (because BCL APIs cannot modify the input arguments they were given).

public static ProcessTextOutput RunAndCaptureText(string fileName, IEnumerable<string>? arguments = null, TimeSpan? timeout = null)
public static Task<ProcessTextOutput> RunAndCaptureTextAsync(string fileName, IEnumerable<string>? arguments = null, CancellationToken cancellationToken = default)
public static ProcessTextOutput RunAndCaptureText(ProcessStartInfo startInfo, TimeSpan? timeout = null)
public static Task<ProcessTextOutput> RunAndCaptureTextAsync(ProcessStartInfo startInfo, CancellationToken cancellationToken = default)
Process.StartAndForget

There is a common misconception that when a process is disposed, it's also being killed. This is not the case, as Process.Dispose only releases the resources associated with the process, but does not kill it.

To make it easier to start a process without the need to worry about disposing it, Process.StartAndForget was introduced. The method starts an executable, retu

자주 묻는 질문

.NET 10에서도 되나요?

아니요. 이 API는 .NET 11 이상에만 있습니다.

기본 Process.Start도 여전히 동작하나요?

네. 출력 캡처나 새 수명 규칙이 필요 없다면 기본 방식으로 충분합니다.

KillOnParentExit은 무엇을 하나요?

부모 프로세스가 끝나면 자식 프로세스를 자동으로 멈추게 합니다.

상세 정보

작성자의 원본 설명

Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText/Bytes/Lines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.

repo: dotnet/skills

인기도

GitHub 스타
5.8k
순위
#14655
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬