1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-21 06:44:45 -05:00
denoland-deno/tests/specs/task/signals/signals.ts

66 lines
1.2 KiB
TypeScript
Raw Normal View History

const signals = [
"SIGABRT",
"SIGALRM",
"SIGBUS",
"SIGCHLD",
"SIGCONT",
"SIGEMT",
"SIGFPE",
"SIGHUP",
"SIGILL",
"SIGINFO",
"SIGINT",
"SIGIO",
"SIGPOLL",
"SIGPIPE",
"SIGPROF",
"SIGPWR",
"SIGQUIT",
"SIGSEGV",
"SIGSTKFLT",
"SIGSYS",
"SIGTERM",
"SIGTRAP",
"SIGTSTP",
"SIGTTIN",
"SIGTTOU",
"SIGURG",
"SIGUSR1",
"SIGUSR2",
"SIGVTALRM",
"SIGWINCH",
"SIGXCPU",
"SIGXFSZ",
] as const;
// SIGKILL and SIGSTOP are not stoppable, SIGBREAK is for windows, and SIGUNUSED is not defined
type SignalsToTest = Exclude<
Deno.Signal,
"SIGKILL" | "SIGSTOP" | "SIGBREAK" | "SIGUNUSED"
>;
type EnsureAllSignalsIncluded = SignalsToTest extends typeof signals[number]
? typeof signals[number] extends SignalsToTest ? true
: never
: never;
const _checkSignals: EnsureAllSignalsIncluded = true;
const osSpecificSignals = signals.filter((s) => {
switch (s) {
case "SIGEMT":
return Deno.build.os === "darwin";
case "SIGINFO":
case "SIGFPE":
case "SIGILL":
case "SIGSEGV":
return Deno.build.os === "freebsd";
case "SIGPOLL":
case "SIGPWR":
case "SIGSTKFLT":
return Deno.build.os === "linux";
default:
return true;
}
});
export { osSpecificSignals as signals };