1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
5 using System.Runtime.Versioning;
7 namespace System.Runtime.InteropServices
9 /// <summary>Handles a <see cref="PosixSignal"/>.</summary>
10 public sealed partial class PosixSignalRegistration : IDisposable
12 /// <summary>Registers a <paramref name="handler"/> that is invoked when the <paramref name="signal"/> occurs.</summary>
13 /// <param name="signal">The signal to register for.</param>
14 /// <param name="handler">The handler that gets invoked.</param>
15 /// <returns>A <see cref="PosixSignalRegistration"/> instance that can be disposed to unregister the handler.</returns>
16 /// <exception cref="ArgumentNullException"><paramref name="handler"/> is <see langword="null"/>.</exception>
17 /// <exception cref="PlatformNotSupportedException"><paramref name="signal"/> is not supported by the platform.</exception>
18 /// <exception cref="IOException">An error occurred while setting up the signal handling or while installing the handler for the specified signal.</exception>
20 /// Raw values can be provided for <paramref name="signal"/> on Unix by casting them to <see cref="PosixSignal"/>.
21 /// Default handling of the signal can be canceled through <see cref="PosixSignalContext.Cancel"/>.
22 /// <see cref="PosixSignal.SIGINT"/> and <see cref="PosixSignal.SIGQUIT"/> can be canceled on both
23 /// Windows and on Unix platforms; <see cref="PosixSignal.SIGTERM"/> can only be canceled on Unix.
24 /// On Unix, terminal configuration can be canceled for <see cref="PosixSignal.SIGCHLD"/> and <see cref="PosixSignal.SIGCONT"/>.
26 [UnsupportedOSPlatform("android")]
27 [UnsupportedOSPlatform("browser")]
28 [UnsupportedOSPlatform("ios")]
29 [UnsupportedOSPlatform("maccatalyst")]
30 [UnsupportedOSPlatform("tvos")]
31 public static partial PosixSignalRegistration Create(PosixSignal signal, Action<PosixSignalContext> handler);
33 /// <summary>Unregister the handler.</summary>
34 public partial void Dispose();
36 ~PosixSignalRegistration() => Dispose();