J Reece Wilson
766be57a46
[+] ProcessSectionViewReserved.Unix.cpp [*] Fix missing ::Flush() member on ViewWriter
59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
/***
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
File: AuExit.Unix.cpp
|
|
Date: 2022-4-7
|
|
Author: Reece
|
|
***/
|
|
#include <Source/RuntimeInternal.hpp>
|
|
#include "AuExit.hpp"
|
|
#include "AuExit.Unix.hpp"
|
|
#include <Source/Grug/AuGrug.hpp>
|
|
|
|
namespace Aurora::Exit
|
|
{
|
|
static void SendExitSignal(Grug::Arrow *)
|
|
{
|
|
PostLevel(AuThreads::GetThread(), Exit::ETriggerLevel::eSigTerminate);
|
|
}
|
|
|
|
static void HandleSigTerminate(int sig)
|
|
{
|
|
static Grug::Arrow arrow;
|
|
|
|
if (sig == SIGINT)
|
|
{
|
|
Grug::HurlArrow(&arrow, {}, SendExitSignal);
|
|
}
|
|
else
|
|
{
|
|
Grug::HurlArrow(&arrow, SendExitSignal, {});
|
|
Grug::ArrowWait(&arrow);
|
|
}
|
|
}
|
|
|
|
void InitUnix()
|
|
{
|
|
struct sigaction action =
|
|
{
|
|
.sa_handler = HandleSigTerminate,
|
|
.sa_flags = SA_ONSTACK
|
|
};
|
|
sigemptyset(&action.sa_mask);
|
|
|
|
sigaction(SIGINT, &action, nullptr);
|
|
//sigaction(SIGTERM, &action, nullptr);
|
|
}
|
|
|
|
void DeinitUnix()
|
|
{
|
|
struct sigaction action =
|
|
{
|
|
.sa_handler = SIG_DFL,
|
|
.sa_flags = SA_ONSTACK
|
|
};
|
|
sigemptyset(&action.sa_mask);
|
|
|
|
sigaction(SIGINT, &action, nullptr);
|
|
//sigaction(SIGTERM, &action, nullptr);
|
|
}
|
|
} |