Skip to content

Latest commit

 

History

History
61 lines (54 loc) · 2.71 KB

File metadata and controls

61 lines (54 loc) · 2.71 KB

System.Diagnostics


ProcessExtensions

Extension methods for System.Diagnostics.Process that add async-friendly waiting and cross-platform process-tree termination.

public static class ProcessExtensions

Static Methods

KillTree

void KillTree(this Process process)

Summary: Synchronously terminates the process and any child processes it started, using a default 30-second timeout per spawned helper command. On Windows uses taskkill /T /F; on other platforms uses pgrep + kill -TERM.

Parameters:
     process  -  The root process whose tree should be terminated.

KillTree

void KillTree(this Process process, TimeSpan timeout)

Summary: Synchronously terminates the process and any child processes it started, using a default 30-second timeout per spawned helper command. On Windows uses taskkill /T /F; on other platforms uses pgrep + kill -TERM.

Parameters:
     process  -  The root process whose tree should be terminated.

KillTreeAsync

Task KillTreeAsync(this Process process, CancellationToken cancellationToken = null)

Summary: Asynchronously terminates the process and any child processes it started, using the default 30-second timeout per helper command.

Parameters:
     process  -  The root process whose tree should be terminated.
     cancellationToken  -  Token used to abort the kill operation early.

Returns: A task that completes when the kill commands have finished.

KillTreeAsync

Task KillTreeAsync(this Process process, TimeSpan timeout, CancellationToken cancellationToken = null)

Summary: Asynchronously terminates the process and any child processes it started, using the default 30-second timeout per helper command.

Parameters:
     process  -  The root process whose tree should be terminated.
     cancellationToken  -  Token used to abort the kill operation early.

Returns: A task that completes when the kill commands have finished.

WaitForExitAsync

Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = null)

Generated by MarkdownCodeDoc version 1.2