Background and motivation
ProcessExitStatus is added in .NET 11 to represent the exit status of a process. It has three properties: ExitCode, Signal, and Canceled.
The Canceled property indicates whether the process was killed due to timeout or cancellation by either the SafeProcessHandle.WaitForExitOrKillOnTimeout or SafeProcessHandle.WaitForExitOrKillOnCancellationAsync APIs.
This proposes to use Killed in the status to indicate that the process was terminated by .NET. This decouples it from the above APIs.
API Proposal
namespace System.Diagnostics;
public sealed class ProcessExitStatus
{
- public ProcessExitStatus(int exitCode, bool canceled, PosixSignal? signal = null);
+ public ProcessExitStatus(int exitCode, bool killed, PosixSignal? signal = null);
public int ExitCode { get; }
public PosixSignal? Signal { get; }
- public bool Canceled { get; }
+ public bool Killed { get; }
}
Alternatives
Instead of renaming Canceled, it could be removed entirely and a user can use Signal instead. On Unix, this is set already to PosixSignal.SIGKILL. On Windows, we could do the same when the process is killed by .NET.
Background and motivation
ProcessExitStatusis added in .NET 11 to represent the exit status of a process. It has three properties:ExitCode,Signal, andCanceled.The
Canceledproperty indicates whether the process was killed due to timeout or cancellation by either theSafeProcessHandle.WaitForExitOrKillOnTimeoutorSafeProcessHandle.WaitForExitOrKillOnCancellationAsyncAPIs.This proposes to use
Killedin the status to indicate that the process was terminated by .NET. This decouples it from the above APIs.API Proposal
namespace System.Diagnostics; public sealed class ProcessExitStatus { - public ProcessExitStatus(int exitCode, bool canceled, PosixSignal? signal = null); + public ProcessExitStatus(int exitCode, bool killed, PosixSignal? signal = null); public int ExitCode { get; } public PosixSignal? Signal { get; } - public bool Canceled { get; } + public bool Killed { get; } }Alternatives
Instead of renaming
Canceled, it could be removed entirely and a user can useSignalinstead. On Unix, this is set already toPosixSignal.SIGKILL. On Windows, we could do the same when the process is killed by .NET.