diff options
author | 2023-05-27 23:33:47 -0700 | |
---|---|---|
committer | 2023-05-27 23:33:47 -0700 | |
commit | 1388ec0d60e77cb0d71475fef33ab5764501b208 (patch) | |
tree | 738ff1c1382e4f3878db7826ece9b023095ce184 | |
parent | 4ba3ed512ac8407603c99d56d931038e0bdf0884 (diff) | |
download | bun-1388ec0d60e77cb0d71475fef33ab5764501b208.tar.gz bun-1388ec0d60e77cb0d71475fef33ab5764501b208.tar.zst bun-1388ec0d60e77cb0d71475fef33ab5764501b208.zip |
Fixes #2356 (#3098)
-rw-r--r-- | .vscode/launch.json | 67 | ||||
-rw-r--r-- | src/bun.js/bindings/c-bindings.cpp | 7 | ||||
-rw-r--r-- | src/crash_reporter.zig | 28 |
3 files changed, 66 insertions, 36 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json index 08ecd7f8f..84b1f6557 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,10 +7,29 @@ "name": "bun test", "program": "bun-debug", "args": ["test", "${file}"], - "cwd": "${workspaceFolder}", + "cwd": "${file}/../", "env": { - "FORCE_COLOR": "1" + "FORCE_COLOR": "1", + "BUN_DEBUG_QUIET_LOGS": "1", + "BUN_GARBAGE_COLLECTOR_LEVEL": "2" + }, + // SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits. + "initCommands": ["process handle -p false -s false -n false SIGHUP"], + "console": "internalConsole" + }, + { + "type": "lldb", + "request": "launch", + "name": "bun test (fast)", + "program": "bun-debug", + "args": ["test", "${file}"], + "cwd": "${file}/../", + "env": { + "FORCE_COLOR": "1", + "BUN_DEBUG_QUIET_LOGS": "1" }, + // SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits. + "initCommands": ["process handle -p false -s false -n false SIGHUP"], "console": "internalConsole" }, { @@ -23,21 +42,37 @@ "env": { "FORCE_COLOR": "1" }, - "console": "internalConsole" + "console": "internalConsole", + // SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits. + "initCommands": ["process handle -p false -s false -n false SIGHUP"] }, { "type": "lldb", "request": "launch", "name": "bun test (all)", "program": "bun-debug", + "cwd": "${workspaceFolder}", + "env": { + "BUN_DEBUG_QUIET_LOGS": "1", + "BUN_GARBAGE_COLLECTOR_LEVEL": "2" + }, + "console": "internalConsole", + // SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits. + "initCommands": ["process handle -p false -s false -n false SIGHUP"] + }, + { + "type": "lldb", + "request": "launch", + "name": "bun test (all, fast)", + "program": "bun-debug", "args": ["test"], - "cwd": "${workspaceFolder}/test", + "cwd": "${workspaceFolder}", "env": { - "FORCE_COLOR": "1", - "BUN_GARBAGE_COLLECTOR_LEVEL": "2", "BUN_DEBUG_QUIET_LOGS": "1" }, - "console": "internalConsole" + "console": "internalConsole", + // SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits. + "initCommands": ["process handle -p false -s false -n false SIGHUP"] }, { "type": "lldb", @@ -49,7 +84,9 @@ "env": { "FORCE_COLOR": "1" }, - "console": "internalConsole" + "console": "internalConsole", + // SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits. + "initCommands": ["process handle -p false -s false -n false SIGHUP"] }, { "type": "lldb", @@ -73,7 +110,9 @@ "env": { "FORCE_COLOR": "1" }, - "console": "internalConsole" + "console": "internalConsole", + // SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits. + "initCommands": ["process handle -p false -s false -n false SIGHUP"] }, { "type": "lldb", @@ -98,7 +137,9 @@ "env": { "FORCE_COLOR": "1" }, - "console": "internalConsole" + "console": "internalConsole", + // SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits. + "initCommands": ["process handle -p false -s false -n false SIGHUP"] }, { "type": "lldb", @@ -139,12 +180,14 @@ "request": "launch", "name": "bun build debug", "program": "bun-debug", - "args": ["bun", "./test/fixtures/bundle/trivial/index.js"], + "args": ["bun", "${file}"], "cwd": "${workspaceFolder}", "console": "internalConsole", "env": { "BUN_CONFIG_MINIFY_WHITESPACE": "1" - } + }, + // SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits. + "initCommands": ["process handle -p false -s false -n false SIGHUP"] }, { "type": "lldb", diff --git a/src/bun.js/bindings/c-bindings.cpp b/src/bun.js/bindings/c-bindings.cpp index 90cb5e310..0e837d04f 100644 --- a/src/bun.js/bindings/c-bindings.cpp +++ b/src/bun.js/bindings/c-bindings.cpp @@ -4,6 +4,7 @@ #include <unistd.h> #include <sys/fcntl.h> #include <sys/stat.h> +#include <sys/signal.h> extern "C" int32_t get_process_priority(uint32_t pid) { @@ -34,3 +35,9 @@ extern "C" bool is_executable_file(const char* path) // regular file and user can execute return S_ISREG(st.st_mode) && (st.st_mode & S_IXUSR); } + +extern "C" void bun_ignore_sigpipe() +{ + // ignore SIGPIPE + signal(SIGPIPE, SIG_IGN); +}
\ No newline at end of file diff --git a/src/crash_reporter.zig b/src/crash_reporter.zig index e1ac54190..b583db248 100644 --- a/src/crash_reporter.zig +++ b/src/crash_reporter.zig @@ -44,17 +44,7 @@ pub fn reloadHandlers() !void { try setup_sigactions(&act); - var pipe = os.Sigaction{ - .handler = .{ .sigaction = sigpipe_handler }, - .mask = os.empty_sigset, - .flags = (os.SA.SIGINFO | os.SA.RESTART | os.SA.RESETHAND), - }; - - try os.sigaction( - os.SIG.PIPE, - &pipe, - null, - ); + bun_ignore_sigpipe(); } const os = std.os; pub fn start() !void { @@ -65,17 +55,7 @@ pub fn start() !void { }; try setup_sigactions(&act); - { - var pipe = os.Sigaction{ - .handler = .{ .sigaction = sigpipe_handler }, - .mask = os.empty_sigset, - .flags = (os.SA.SIGINFO | os.SA.RESTART | os.SA.RESETHAND), - }; - - try os.sigaction( - os.SIG.PIPE, - &pipe, - null, - ); - } + bun_ignore_sigpipe(); } + +extern fn bun_ignore_sigpipe() void; |