mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
dd1ebbd31b
This requires an API introduced in MacOS 11. I think that's fine, since the version before that (MacOS 10.15) is EOL since 2022. Though if needed, we could certainly work around it by using an older and slightly less nice API.
33 lines
790 B
C
33 lines
790 B
C
//go:build none
|
|
|
|
// Ignore the //go:build above. This file is manually included on Linux and
|
|
// MacOS to provide os/signal support.
|
|
|
|
#include <stdint.h>
|
|
#include <signal.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
|
|
// Signal handler in the runtime.
|
|
void tinygo_signal_handler(int sig);
|
|
|
|
// Enable a signal from the runtime.
|
|
void tinygo_signal_enable(uint32_t sig) {
|
|
struct sigaction act = { 0 };
|
|
act.sa_handler = &tinygo_signal_handler;
|
|
act.sa_flags = SA_RESTART;
|
|
sigaction(sig, &act, NULL);
|
|
}
|
|
|
|
void tinygo_signal_ignore(uint32_t sig) {
|
|
struct sigaction act = { 0 };
|
|
act.sa_handler = SIG_IGN;
|
|
sigaction(sig, &act, NULL);
|
|
}
|
|
|
|
void tinygo_signal_disable(uint32_t sig) {
|
|
struct sigaction act = { 0 };
|
|
act.sa_handler = SIG_DFL;
|
|
sigaction(sig, &act, NULL);
|
|
}
|