feat(headless): complete portable single-session host
This commit is contained in:
parent
fbebb91848
commit
f8cb840fb1
30 changed files with 3571 additions and 32 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue