Table of Contents

Class ProcessRunner

Namespace
McServerLauncher.Services
Assembly
McServerLauncher.dll

Runs a short external command and collects what it printed, within a deadline that holds.

public static class ProcessRunner
Inheritance
ProcessRunner
Inherited Members

Remarks

The helpers this replaces read standard output to its end and only then called WaitForExit(5000). Reading to the end already waits for the process to finish, so the five seconds never applied: a systemctl start waiting on a polkit prompt, or anything else that hangs, held its caller for as long as it liked. And reading one stream to the end before the other can deadlock a process that fills the second one's buffer first.

Here both streams are read at once and the deadline is real: past it the process tree is killed and the result says so with an exit code of -1.

Methods

Run(string, IEnumerable<string>, TimeSpan)

Runs file with arguments. Never throws.

public static ProcessRunner.Result Run(string file, IEnumerable<string> arguments, TimeSpan timeout)

Parameters

file string
arguments IEnumerable<string>
timeout TimeSpan

Returns

ProcessRunner.Result