Skip to content

Commit 6e03551

Browse files
authored
Add breaking change documentation for .NET runtime SIGTERM signal handler removal (#46599)
1 parent 0b171a0 commit 6e03551

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

docs/core/compatibility/10.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
3232
| [Default trace context propagator updated to W3C standard](core-libraries/10.0/default-trace-context-propagator.md) | Behavioral change | Preview 4 |
3333
| [LDAP DirectoryControl parsing is now more stringent](core-libraries/10.0/ldap-directorycontrol-parsing.md) | Behavioral change | Preview 1 |
3434
| [MacCatalyst version normalization](core-libraries/10.0/maccatalyst-version-normalization.md) | Behavioral change | Preview 1 |
35+
| [.NET runtime no longer provides default SIGTERM signal handler](core-libraries/10.0/sigterm-signal-handler.md) | Behavioral change | Preview 5 |
3536
| [System.Linq.AsyncEnumerable included in core libraries](core-libraries/10.0/asyncenumerable.md) | Source incompatible | Preview 1 |
3637
| [YMM embedded rounding removed from AVX10.2](core-libraries/10.0/ymm-embedded-rounding.md) | Behavioral change | Preview 5 |
3738

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "Breaking change: .NET runtime no longer provides default SIGTERM signal handler"
3+
description: "Learn about the breaking change in .NET 10 where the runtime no longer provides a default SIGTERM signal handler."
4+
ms.date: 06/06/2025
5+
ai-usage: ai-assisted
6+
ms.custom: https://github.com/dotnet/docs/issues/46226
7+
---
8+
# .NET runtime no longer provides default SIGTERM signal handler
9+
10+
On Unix systems, the .NET runtime no longer provides a default SIGTERM signal handler. On Windows, the .NET runtime no longer provides default handlers for the [`CTRL_CLOSE_EVENT` and `CTRL_SHUTDOWN_EVENT` signals](/windows/console/handlerroutine), which are equivalents of Unix `SIGTERM` signal.
11+
12+
This change reverts the SIGTERM signal handling behavior to what it used to be in .NET Framework and classic Mono runtime.
13+
14+
## Version introduced
15+
16+
.NET 10 Preview 5
17+
18+
## Previous behavior
19+
20+
Previously, a SIGTERM signal handler registered by the .NET runtime by default triggered graceful application exit. <xref:System.AppDomain.ProcessExit?displayProperty=nameWithType> and <xref:System.Runtime.Loader.AssemblyLoadContext.Unloading?displayProperty=nameWithType> events were raised before the application exited.
21+
22+
## New behavior
23+
24+
Starting in .NET 10, the .NET runtime does not override SIGTERM signal handling provided by the operating system. The typical default SIGTERM signal handler provided by the operating system terminates the application immediately. <xref:System.AppDomain.ProcessExit?displayProperty=nameWithType> and <xref:System.Runtime.Loader.AssemblyLoadContext.Unloading?displayProperty=nameWithType> events aren't raised.
25+
26+
## Type of breaking change
27+
28+
This is a [behavioral change](../../categories.md#behavioral-change).
29+
30+
## Reason for change
31+
32+
The SIGTERM signal handler registered by the .NET runtime by default was both insufficient for some app models (for example, console and containerized applications) and incompatible with other app models (for example, Windows services). It's better to leave it to higher-level libraries or application code to register signal handlers appropriate for the given app model.
33+
34+
## Recommended action
35+
36+
- No action is necessary for typical ASP.NET applications or applications that use higher-level APIs such as <xref:Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.UseConsoleLifetime*?displayProperty=nameWithType> to handle app-model specific concerns. These higher-level APIs register handlers for SIGTERM and other signals as appropriate.
37+
38+
- If you want to handle SIGTERM signal without taking a dependency on higher-level libraries, you can replicate the previous behavior by creating a SIGTERM signal handler in your `Main` method using the <xref:System.Runtime.InteropServices.PosixSignalRegistration.Create%2A?displayProperty=nameWithType> API:
39+
40+
```csharp
41+
static void Main()
42+
{
43+
using var termSignalRegistration =
44+
PosixSignalRegistration.Create(
45+
PosixSignal.SIGTERM,
46+
(_) => Environment.Exit(0));
47+
48+
// Your application code here
49+
}
50+
```
51+
52+
## Affected APIs
53+
54+
- <xref:System.AppDomain.ProcessExit?displayProperty=fullName>
55+
- <xref:System.Runtime.Loader.AssemblyLoadContext.Unloading?displayProperty=fullName>

docs/core/compatibility/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ items:
2828
href: core-libraries/10.0/ldap-directorycontrol-parsing.md
2929
- name: MacCatalyst version normalization
3030
href: core-libraries/10.0/maccatalyst-version-normalization.md
31+
- name: No default SIGTERM signal handler
32+
href: core-libraries/10.0/sigterm-signal-handler.md
3133
- name: System.Linq.AsyncEnumerable included in core libraries
3234
href: core-libraries/10.0/asyncenumerable.md
3335
- name: YMM embedded rounding removed from AVX10.2
@@ -1424,6 +1426,8 @@ items:
14241426
href: core-libraries/10.0/ldap-directorycontrol-parsing.md
14251427
- name: MacCatalyst version normalization
14261428
href: core-libraries/10.0/maccatalyst-version-normalization.md
1429+
- name: No default SIGTERM signal handler
1430+
href: core-libraries/10.0/sigterm-signal-handler.md
14271431
- name: System.Linq.AsyncEnumerable included in core libraries
14281432
href: core-libraries/10.0/asyncenumerable.md
14291433
- name: YMM embedded rounding removed from AVX10.2

0 commit comments

Comments
 (0)