Repository: dotnet/runtime
File: src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessExitStatus.cs (C#)

Code before:
        /// Initializes a new instance of the <see cref="ProcessExitStatus"/> class.
        /// </summary>
        /// <param name="exitCode">The exit code of the process.</param>
        /// <param name="canceled">A value indicating whether the process has been terminated due to timeout or cancellation.</param>
        /// <param name="signal">The POSIX signal that terminated the process, or null if the process exited normally.</param>
        public ProcessExitStatus(int exitCode, bool canceled, PosixSignal? signal = null)
        {
            ExitCode = exitCode;
            Canceled = canceled;
            Signal = signal;
        }

        /// <summary>
        /// Gets the exit code of the process.
        /// </summary>
        /// <remarks>
        /// <para>On Windows, this is the value passed to ExitProcess or returned from main().</para>
        /// <para>On Unix, if the process exited normally, this is the value passed to exit() or returned from main().</para>
        /// <para>
        /// If the process was terminated by a signal on Unix, this is 128 + the signal number.
        /// Use <see cref="Signal"/> to get the actual signal.
        /// </para>
        /// </remarks>
        public int ExitCode { get; }

        /// <summary>
        /// Gets the POSIX signal that terminated the process, or null if the process exited normally.
        /// </summary>
        /// <remarks>
        /// When produced by <see cref="Process"/> APIs on Windows, this property is always <see langword="null" />.
        /// </remarks>
        public PosixSignal? Signal { get; }

        /// <summary>
        /// Gets a value indicating whether the process has been terminated due to timeout or cancellation.
        /// </summary>
        public bool Canceled { get; }
    }
}


Review comment (suggestion):
Instead of this API, I am wondering whether it would make more sense to have an API like:

`static bool TryMapExitCodeToPosixSignal(int exitCode, out PosixSignal signal)` to better indicate the `errorCode` to signal mapping is opportunistic.

Code after:
        /// Initializes a new instance of the <see cref="ProcessExitStatus"/> class.
        /// </summary>
        /// <param name="exitCode">The exit code of the process.</param>
        /// <param name="canceled">A value indicating whether the process has been terminated due to timeout or cancellation.</param>
        /// <param name="signal">On Unix, the POSIX signal that terminated the process, or null if the process exited normally.</param>
        public ProcessExitStatus(int exitCode, bool canceled, PosixSignal? signal = null)
        {
            ExitCode = exitCode;
            Canceled = canceled;
            Signal = signal;
        }

        /// <summary>
        /// Gets the exit code of the process.
        /// </summary>
        /// <remarks>
        /// <para>
        /// If the process was terminated by a signal on Unix, this is 128 + the signal number.
        /// Use <see cref="Signal"/> to get the actual signal.
        /// </para>
        /// </remarks>
        public int ExitCode { get; }

        /// <summary>
        /// Gets the POSIX signal that terminated the process on Unix, or <see langword="null" /> if the process was not terminated by a signal.
        /// </summary>
        /// <remarks>
        /// <para>
        /// On Unix, a process can be terminated by a signal (e.g., SIGKILL, SIGTERM). When this happens,
        /// the kernel reports "terminated by signal X" rather than an exit code. This property captures
        /// that signal. When the process exits normally on Unix, or on Windows where signals do not exist,
        /// this property is <see langword="null" />.
        /// </para>
        /// </remarks>
        public PosixSignal? Signal { get; }

        /// <summary>
        /// Gets a value indicating whether the process has been terminated due to timeout or cancellation.
        /// </summary>
        public bool Canceled { get; }
    }
}