Files
bun.sh/test/js/node/process/call-raise.js
Dylan Conway 5c8726d602 process signal events (#3569)
* signal events

* simple tests

* ignore SIGSTOP

* better tests

* use `EventEmitter`

* use `Bun__getDefaultGlobal`

* progress

* don't use 'Bun__getDefaultGlobal`

* fix tests

* remove signals from map

* update tests

* don't overwrite event emitter methods

* avoid two lookups

* use `std::once`

* releaseEarly()

* Remove signal handler after use

* Update call-raise.js

* Create process-signal-handler.fixture.js

* Don't register duplicates

* Add missing lock

* another test

* update test

* revert some changes

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-11 12:48:46 -07:00

16 lines
334 B
JavaScript

import { dlopen } from "bun:ffi";
var lazyRaise;
export function raise(signal) {
if (!lazyRaise) {
const suffix = process.platform === "darwin" ? "dylib" : "so.6";
lazyRaise = dlopen(`libc.${suffix}`, {
raise: {
args: ["int"],
returns: "int",
},
}).symbols.raise;
}
lazyRaise(signal);
}