mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
React appropriate to SIGINT (CTRL+C)
We're using custom console mechanism in order to implement interactive console, on top of that CTRL+C would not work when using IPC: true due to the fact that it doesn't trigger shutdown sequence, fix both of those problems by listening to SIGINT and exiting with code 130 upon receiving one Tested on Linux
This commit is contained in:
@@ -125,6 +125,8 @@ namespace ArchiSteamFarm {
|
|||||||
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
||||||
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
|
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
|
||||||
|
|
||||||
|
Console.CancelKeyPress += OnCancelKeyPress;
|
||||||
|
|
||||||
// Add support for custom encodings
|
// Add support for custom encodings
|
||||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
|
||||||
@@ -396,6 +398,8 @@ namespace ArchiSteamFarm {
|
|||||||
return await ShutdownResetEvent.Task.ConfigureAwait(false);
|
return await ShutdownResetEvent.Task.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async void OnCancelKeyPress(object? sender, ConsoleCancelEventArgs e) => await Exit(130).ConfigureAwait(false);
|
||||||
|
|
||||||
private static async void OnProcessExit(object? sender, EventArgs e) => await Shutdown().ConfigureAwait(false);
|
private static async void OnProcessExit(object? sender, EventArgs e) => await Shutdown().ConfigureAwait(false);
|
||||||
|
|
||||||
private static async void OnUnhandledException(object? sender, UnhandledExceptionEventArgs e) {
|
private static async void OnUnhandledException(object? sender, UnhandledExceptionEventArgs e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user