Repository: dotnet/runtime
File: src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PosixSignalRegistration.cs (C#)

Code before:
        /// <param name="signal">The signal to register for.</param>
        /// <param name="handler">The handler that gets invoked.</param>
        /// <returns>A <see cref="PosixSignalRegistration"/> instance that can be disposed to unregister the handler.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="handler"/> is <see langword="null"/>.</exception>
        /// <exception cref="PlatformNotSupportedException"><paramref name="signal"/> is not supported by the platform.</exception>
        /// <exception cref="IOException">An error occurred while setting up the signal handling or while installing the handler for the specified signal.</exception>
        /// <remarks>
        /// The handlers are executed in reverse order of their registration.
        /// Raw values can be provided for <paramref name="signal"/> on Unix by casting them to <see cref="PosixSignal"/>.
        /// Default handling of the signal can be canceled through <see cref="PosixSignalContext.Cancel"/>.
        /// <see cref="PosixSignal.SIGINT"/> and <see cref="PosixSignal.SIGQUIT"/> can be canceled on both
        /// Windows and on Unix platforms; <see cref="PosixSignal.SIGTERM"/> can only be canceled on Unix.
        /// On Unix, terminal configuration can be canceled for <see cref="PosixSignal.SIGCHLD"/> and <see cref="PosixSignal.SIGCONT"/>.
        /// </remarks>
        [UnsupportedOSPlatform("android")]
        [UnsupportedOSPlatform("browser")]
        [UnsupportedOSPlatform("ios")]
        [UnsupportedOSPlatform("tvos")]
        public static PosixSignalRegistration Create(PosixSignal signal, Action<PosixSignalContext> handler)
        {
            ArgumentNullException.ThrowIfNull(handler);

            // SIGKILL cannot be caught or ignored on any OS.
            // Check for both the enum value (PosixSignal.SIGKILL = -11) and the raw POSIX signal number (9)
            // cast to the enum type (e.g., (PosixSignal)9).
            if (signal == PosixSignal.SIGKILL || (int)signal == SIGKILL_POSIX_SIGNAL_NUMBER)
            {
                throw new ArgumentException(SR.Arg_CannotRegisterHandlerForSIGKILL, nameof(signal));
            }

            return Register(signal, handler);
        }

        /// <summary>Initializes the registration to wrap the specified token.</summary>
        private PosixSignalRegistration(Token token) => _token = token;

        /// <summary>Unregister the handler.</summary>
        public void Dispose()
        {
            Unregister();
            GC.SuppressFinalize(this);
        }

        /// <summary>Unregister the handler.</summary>
        ~PosixSignalRegistration() => Unregister();

        /// <summary>The state associated with a registration.</summary>
        private sealed class Token
        {
            public Token(PosixSignal signal, Action<PosixSignalContext> handler)
            {

Review comment (suggestion):
The check for `SIGKILL_POSIX_SIGNAL_NUMBER` is a breaking change. It is changing the exception thrown for attempt to register SIGKILL with the raw signal number.

Code after:
        /// <exception cref="ArgumentNullException"><paramref name="handler"/> is <see langword="null"/>.</exception>
        /// <exception cref="PlatformNotSupportedException"><paramref name="signal"/> is not supported by the platform.</exception>
        /// <exception cref="IOException">An error occurred while setting up the signal handling or while installing the handler for the specified signal.</exception>
        /// <remarks>
        /// The handlers are executed in reverse order of their registration.
        /// Raw values can be provided for <paramref name="signal"/> on Unix by casting them to <see cref="PosixSignal"/>.
        /// Default handling of the signal can be canceled through <see cref="PosixSignalContext.Cancel"/>.
        /// <see cref="PosixSignal.SIGINT"/> and <see cref="PosixSignal.SIGQUIT"/> can be canceled on both
        /// Windows and on Unix platforms; <see cref="PosixSignal.SIGTERM"/> can only be canceled on Unix.
        /// On Unix, terminal configuration can be canceled for <see cref="PosixSignal.SIGCHLD"/> and <see cref="PosixSignal.SIGCONT"/>.
        /// </remarks>
        [UnsupportedOSPlatform("android")]
        [UnsupportedOSPlatform("browser")]
        [UnsupportedOSPlatform("ios")]
        [UnsupportedOSPlatform("tvos")]
        public static PosixSignalRegistration Create(PosixSignal signal, Action<PosixSignalContext> handler)
        {
            ArgumentNullException.ThrowIfNull(handler);

            return Register(signal, handler);
        }

        /// <summary>Initializes the registration to wrap the specified token.</summary>
        private PosixSignalRegistration(Token token) => _token = token;

        /// <summary>Unregister the handler.</summary>
        public void Dispose()
        {
            Unregister();
            GC.SuppressFinalize(this);
        }

        /// <summary>Unregister the handler.</summary>
        ~PosixSignalRegistration() => Unregister();

        /// <summary>The state associated with a registration.</summary>
        private sealed class Token
        {
            public Token(PosixSignal signal, Action<PosixSignalContext> handler)
            {
                Signal = signal;
                Handler = handler;
            }

            public Token(PosixSignal signal, int sigNo, Action<PosixSignalContext> handler)
            {
                Signal = signal;
                Handler = handler;
                SigNo = sigNo;
            }