Skip to content

Commit 45da191

Browse files
committed
human edits
1 parent 8907d2a commit 45da191

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

docs/core/compatibility/core-libraries/10.0/sigterm-signal-handler.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
title: "Breaking change: .NET runtime no longer provides default SIGTERM signal handler"
33
description: "Learn about the breaking change in .NET 10 where the runtime no longer provides a default SIGTERM signal handler."
4-
ms.date: 01/30/2025
4+
ms.date: 06/06/2025
55
ai-usage: ai-assisted
66
ms.custom: https://github.com/dotnet/docs/issues/46226
77
---
88
# .NET runtime no longer provides default SIGTERM signal handler
99

10-
On Unix systems, .NET runtime no longer provides a default SIGTERM signal handler. On Windows, .NET runtime no longer provides default handlers for `CTRL_CLOSE_EVENT` and `CTRL_SHUTDOWN_EVENT` signals that are equivalents of Unix `SIGTERM` signal.
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.
1111

1212
This change reverts the SIGTERM signal handling behavior to what it used to be in .NET Framework and classic Mono runtime.
1313

@@ -17,33 +17,33 @@ This change reverts the SIGTERM signal handling behavior to what it used to be i
1717

1818
## Previous behavior
1919

20-
Previously, a SIGTERM signal handler registered by .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.
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.
2121

2222
## New behavior
2323

24-
Starting in .NET 10, .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 are not raised.
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.
2525

2626
## Type of breaking change
2727

2828
This is a [behavioral change](../../categories.md#behavioral-change).
2929

3030
## Reason for change
3131

32-
The SIGTERM signal handler registered by .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.
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.
3333

3434
## Recommended action
3535

36-
- No action is necessary for typical ASP.NET applications or applications that use higher level APIs such as `HostingHostBuilderExtensions.UseConsoleLifetime` to handle app-model specific concerns. These higher-level APIs register handlers for SIGTERM and other signals as appropriate.
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.
3737

38-
- Applications that wish to handle SIGTERM signal without taking a dependency on higher level libraries can replicate the old behavior by creating a SIGTERM signal handler in their Main method using <xref:System.Runtime.InteropServices.PosixSignalRegistration.Create%2A?displayProperty=nameWithType> API:
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:
3939

4040
```csharp
41-
using System;
42-
using System.Runtime.InteropServices;
43-
4441
static void Main()
4542
{
46-
using var termSignalRegistration = PosixSignalRegistration.Create(PosixSignal.SIGTERM, (_) => Environment.Exit(0));
43+
using var termSignalRegistration =
44+
PosixSignalRegistration.Create(
45+
PosixSignal.SIGTERM,
46+
(_) => Environment.Exit(0));
4747

4848
// Your application code here
4949
}

docs/core/compatibility/toc.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ 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: .NET runtime no longer provides default SIGTERM signal handler
31+
- name: No default SIGTERM signal handler
3232
href: core-libraries/10.0/sigterm-signal-handler.md
3333
- name: System.Linq.AsyncEnumerable included in core libraries
3434
href: core-libraries/10.0/asyncenumerable.md
@@ -1414,6 +1414,8 @@ items:
14141414
href: core-libraries/10.0/ldap-directorycontrol-parsing.md
14151415
- name: MacCatalyst version normalization
14161416
href: core-libraries/10.0/maccatalyst-version-normalization.md
1417+
- name: No default SIGTERM signal handler
1418+
href: core-libraries/10.0/sigterm-signal-handler.md
14171419
- name: System.Linq.AsyncEnumerable included in core libraries
14181420
href: core-libraries/10.0/asyncenumerable.md
14191421
- name: .NET 9

0 commit comments

Comments
 (0)