Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bun_core/Global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ macro_rules! for_each_signal {
$cb! {
SIGHUP = 1, SIGINT = 2, SIGQUIT = 3, SIGILL = 4, SIGTRAP = 5, SIGABRT = 6,
SIGBUS = 7, SIGFPE = 8, SIGKILL = 9, SIGUSR1 = 10, SIGSEGV = 11, SIGUSR2 = 12,
SIGPIPE = 13, SIGALRM = 14, SIGTERM = 15, SIG16 = 16, SIGCHLD = 17, SIGCONT = 18,
SIGPIPE = 13, SIGALRM = 14, SIGTERM = 15, SIGSTKFLT = 16, SIGCHLD = 17, SIGCONT = 18,
SIGSTOP = 19, SIGTSTP = 20, SIGTTIN = 21, SIGTTOU = 22, SIGURG = 23, SIGXCPU = 24,
SIGXFSZ = 25, SIGVTALRM = 26, SIGPROF = 27, SIGWINCH = 28, SIGIO = 29, SIGPWR = 30,
SIGSYS = 31,
Expand Down
23 changes: 23 additions & 0 deletions test/js/node/child_process/child_process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fs from "fs";
import { bunEnv, bunExe, isLinux, isWindows, nodeExe, runBunInstall, shellExe, tmpdirSync } from "harness";
import { ChildProcess, exec, execFile, execFileSync, execSync, spawn, spawnSync } from "node:child_process";
import { once } from "node:events";
import os from "node:os";
import { promisify } from "node:util";
import path from "path";
const debug = process.env.DEBUG ? console.log : () => {};
Expand Down Expand Up @@ -542,6 +543,28 @@ it.if(!isWindows)("spawnSync correctly reports signal codes", () => {
expect(signal).toBe("SIGTRAP");
});

// SIGSTKFLT (signal 16 on Linux) used to be reported as the made-up name
// "SIG16" on child exit, even though os.constants.signals and child.kill()
// both spell it "SIGSTKFLT". Node reports "SIGSTKFLT".
it.if(isLinux)("child killed by SIGSTKFLT reports 'SIGSTKFLT', not 'SIG16'", async () => {
expect(os.constants.signals.SIGSTKFLT).toBe(16);

const child = spawn("sleep", ["30"], { stdio: "ignore" });
const { promise, resolve, reject } = Promise.withResolvers<[number | null, string | null]>();
child.on("exit", (code, signal) => resolve([code, signal]));
child.on("error", reject);
await once(child, "spawn");

expect(child.kill("SIGSTKFLT")).toBe(true);
const [code, signal] = await promise;

expect({ code, signal, signalCode: child.signalCode }).toEqual({
code: null,
signal: "SIGSTKFLT",
signalCode: "SIGSTKFLT",
});
});

it("spawnSync(does-not-exist)", () => {
const x = spawnSync("does-not-exist");
expect(x.error?.code).toEqual("ENOENT");
Expand Down
Loading