sh, diff/patch, sort, printf, find, test, getfacl/setfacl/xattr), expanded /proc and metrics (process table, syscalls, replication, net, security posture, worker budget, swarm/replication hints), initd DAG supervision metadata and richer restart journal telemetry, synthetic process groups via IPC (assignProcessGroup/signalProcessGroup) mirrored into process_table, optional kernel.ext.d incremental hot reload (BARE_OS_KERNEL_EXT_D_HOT_RELOAD) with reload audit NDJSON, features proc for hyperblobs dedup and systemd subset documentation, vault threat model doc plus posture fields for AEAD, Pear enclave pointer, account rotation continuity, and Ed25519 consistency across boot manifest / extensions / replication. Adds or extends tests and keeps kernel/ and packages/bare-os-seeder/kernel/ in parity; guest init is bundled from kernel/lib/init/init-main.js via bundle-kernel-init.
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
/**
|
|
* Maps host SIGINT into a process event for guest cancellation (optional `bare-signals` on Bare).
|
|
*/
|
|
|
|
/**
|
|
* @param {{ onSigint?: () => void }} [opts]
|
|
* @returns {Promise<() => void>} disposer
|
|
*/
|
|
export async function installBareOsHostSignalsBridge(opts = {}) {
|
|
const onSigint = typeof opts.onSigint === 'function' ? opts.onSigint : () => {}
|
|
/** @type {(() => void)[]} */
|
|
const disposers = []
|
|
try {
|
|
const mod = await import('bare-signals')
|
|
const Signal = mod.default
|
|
if (typeof Signal === 'function') {
|
|
const h = new Signal('SIGINT')
|
|
const fn = () => {
|
|
onSigint()
|
|
}
|
|
h.on('signal', fn)
|
|
h.start()
|
|
disposers.push(() => {
|
|
try {
|
|
void h.close()
|
|
} catch {
|
|
/* ignore */
|
|
}
|
|
})
|
|
}
|
|
} catch {
|
|
/* bare-signals optional (native binding) */
|
|
}
|
|
if (
|
|
disposers.length === 0 &&
|
|
globalThis.process &&
|
|
typeof globalThis.process.on === 'function'
|
|
) {
|
|
const fn = () => {
|
|
onSigint()
|
|
}
|
|
globalThis.process.on('SIGINT', fn)
|
|
disposers.push(() => {
|
|
try {
|
|
globalThis.process.off('SIGINT', fn)
|
|
} catch {
|
|
/* ignore */
|
|
}
|
|
})
|
|
}
|
|
return () => {
|
|
for (const d of disposers) {
|
|
try {
|
|
d()
|
|
} catch {
|
|
/* ignore */
|
|
}
|
|
}
|
|
}
|
|
}
|