Orginize
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* POSIX.1 Issue 7 signal names accepted by synthetic `kill` / `ctx.bareOsSendSignal`
|
||||
* (delivery is logical; many only update guest state without host semantics).
|
||||
*/
|
||||
export const BARE_OS_POSIX_SIGNAL_NAMES = Object.freeze([
|
||||
'HUP',
|
||||
'INT',
|
||||
'QUIT',
|
||||
'ILL',
|
||||
'TRAP',
|
||||
'ABRT',
|
||||
'BUS',
|
||||
'FPE',
|
||||
'KILL',
|
||||
'USR1',
|
||||
'SEGV',
|
||||
'USR2',
|
||||
'PIPE',
|
||||
'ALRM',
|
||||
'TERM',
|
||||
'STKFLT',
|
||||
'CHLD',
|
||||
'CONT',
|
||||
'STOP',
|
||||
'TSTP',
|
||||
'TTIN',
|
||||
'TTOU',
|
||||
'URG',
|
||||
'XCPU',
|
||||
'XFSZ',
|
||||
'VTALRM',
|
||||
'PROF',
|
||||
'WINCH',
|
||||
'IO',
|
||||
'SYS'
|
||||
])
|
||||
|
||||
/** @type {ReadonlySet<string>} */
|
||||
const SET = new Set(BARE_OS_POSIX_SIGNAL_NAMES)
|
||||
|
||||
/**
|
||||
* @param {string} signal
|
||||
*/
|
||||
export function bareOsNormalizeSignalName(signal) {
|
||||
return String(signal || 'TERM')
|
||||
.replace(/^SIG/i, '')
|
||||
.toUpperCase()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} signal
|
||||
*/
|
||||
export function bareOsIsPosixSignalName(signal) {
|
||||
const s = bareOsNormalizeSignalName(signal)
|
||||
return SET.has(s) || s === '0'
|
||||
}
|
||||
|
||||
/** POSIX-ish default exit status when that signal terminates a session. */
|
||||
export const BARE_OS_SIGNAL_EXIT = Object.freeze({
|
||||
HUP: 1,
|
||||
INT: 2,
|
||||
QUIT: 3,
|
||||
ABRT: 6,
|
||||
KILL: 9,
|
||||
SEGV: 11,
|
||||
ALRM: 14,
|
||||
TERM: 15,
|
||||
XCPU: 24,
|
||||
XFSZ: 25,
|
||||
VTALRM: 26,
|
||||
PROF: 27
|
||||
})
|
||||
|
||||
/** Signals that end the Bare OS session when delivered to pids 1–3. */
|
||||
export const BARE_OS_SESSION_EXIT_SIGNALS = new Set([
|
||||
'HUP',
|
||||
'INT',
|
||||
'QUIT',
|
||||
'ABRT',
|
||||
'KILL',
|
||||
'TERM',
|
||||
'SEGV',
|
||||
'XCPU',
|
||||
'XFSZ',
|
||||
'ALRM',
|
||||
'VTALRM',
|
||||
'PROF'
|
||||
])
|
||||
Reference in New Issue
Block a user