feat(headless): complete portable single-session host

This commit is contained in:
Erik 2026-07-27 07:36:53 +02:00
parent fbebb91848
commit f8cb840fb1
30 changed files with 3571 additions and 32 deletions

View file

@ -1,3 +1,36 @@
using System.Runtime.InteropServices;
using AcDream.Headless;
return HeadlessEntryPoint.Run(args, Console.Out, Console.Error);
using var cancellation = new CancellationTokenSource();
ConsoleCancelEventHandler cancel = (_, eventArgs) =>
{
eventArgs.Cancel = true;
cancellation.Cancel();
};
Console.CancelKeyPress += cancel;
PosixSignalRegistration? terminate = null;
if (!OperatingSystem.IsWindows())
{
terminate = PosixSignalRegistration.Create(
PosixSignal.SIGTERM,
context =>
{
context.Cancel = true;
cancellation.Cancel();
});
}
try
{
return HeadlessEntryPoint.Run(
args,
Console.In,
Console.Out,
Console.Error,
cancellation.Token);
}
finally
{
terminate?.Dispose();
Console.CancelKeyPress -= cancel;
}