Skip to content

Commit

Permalink
fix: compilation issue on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopodl committed May 14, 2024
1 parent 09657e3 commit 760aee5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion argon/vm/signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ARGON_FUNCTION(signal_default_sigint, default_sigint, "", "i: signum", false, fa

bool argon::vm::SignalInit(Context *context) {
static const DefaultHandler def_handlers[] = {
//{&signal_default_sigint, SIGINT}
{nullptr, SIGINT}
};

if (default_handlers != nullptr)
Expand All @@ -45,6 +45,9 @@ bool argon::vm::SignalInit(Context *context) {
return false;

for (auto handler: def_handlers) {
if (handler.handler == nullptr)
continue;

if ((default_handlers[handler.signum] = FunctionNew(handler.handler, nullptr, nullptr)) == nullptr)
goto ERROR;
}
Expand Down Expand Up @@ -106,13 +109,15 @@ void argon::vm::SignalResetHandlers() {
SignalAddHandler(i, default_handlers[i]);
}

#ifndef _ARGON_PLATFORM_WINDOWS
void argon::vm::SignalProcMask() {
sigset_t mask{};

sigfillset(&mask);

pthread_sigmask(SIG_SETMASK, &mask, nullptr);
}
#endif

void signal_handler(int signum) {
ArObject *argv[1];
Expand All @@ -121,6 +126,10 @@ void signal_handler(int signum) {

std::unique_lock lock(handler->lock);

#ifdef _ARGON_PLATFORM_WINDOWS
signal(signum, signal_handler);
#endif

auto *func = IncRef(handler->handler);

lock.unlock();
Expand Down

0 comments on commit 760aee5

Please sign in to comment.