From 58d45da47e2fa65201e01f206f0f43a340218d54 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 15 Mar 2024 02:55:11 +0100 Subject: [PATCH] Lost in the merge --- src/bun.js/api/bun/process.zig | 13 ++++++++++--- src/bun.js/bindings/c-bindings.cpp | 3 ++- src/crash_reporter.zig | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/bun.js/api/bun/process.zig b/src/bun.js/api/bun/process.zig index 551cd72d5c..bfb5c7e500 100644 --- a/src/bun.js/api/bun/process.zig +++ b/src/bun.js/api/bun/process.zig @@ -642,6 +642,8 @@ pub const WaiterThread = if (Environment.isPosix) WaiterThreadPosix else struct } pub fn setShouldUseWaiterThread() void {} + + pub fn reloadHandlers() void {} }; // Machines which do not support pidfd_open (GVisor, Linux Kernel < 5.6) @@ -830,8 +832,10 @@ const WaiterThreadPosix = struct { _ = bun.sys.write(instance.eventfd, &one).unwrap() catch 0; } - pub fn loop() void { - Output.Source.configureNamedThread("Waitpid"); + pub fn reloadHandlers() void { + if (!should_use_waiter_thread) { + return; + } if (comptime Environment.isLinux) { var current_mask = std.os.empty_sigset; @@ -841,10 +845,13 @@ const WaiterThreadPosix = struct { .mask = current_mask, .flags = std.os.SA.NOCLDSTOP, }; - // create a SIGCHLD handler for monitoring child processes std.os.sigaction(std.os.SIG.CHLD, &act, null) catch {}; } + } + pub fn loop() void { + Output.Source.configureNamedThread("Waitpid"); + reloadHandlers(); var this = &instance; outer: while (true) { diff --git a/src/bun.js/bindings/c-bindings.cpp b/src/bun.js/bindings/c-bindings.cpp index 282682de95..05acf8c96a 100644 --- a/src/bun.js/bindings/c-bindings.cpp +++ b/src/bun.js/bindings/c-bindings.cpp @@ -1,5 +1,6 @@ // when we don't want to use @cInclude, we can just stick wrapper functions here #include "root.h" +#include #include #if !OS(WINDOWS) @@ -295,7 +296,7 @@ static inline void make_pos_h_l(unsigned long* pos_h, unsigned long* pos_l, extern "C" ssize_t sys_preadv2(int fd, const struct iovec* iov, int iovcnt, off_t offset, unsigned int flags) { - return syscall(SYS_preadv2, fd, iov, iovcnt, offset, offset>>32, RWF_NOWAIT); + return syscall(SYS_preadv2, fd, iov, iovcnt, offset, offset >> 32, RWF_NOWAIT); } extern "C" ssize_t sys_pwritev2(int fd, const struct iovec* iov, int iovcnt, off_t offset, unsigned int flags) diff --git a/src/crash_reporter.zig b/src/crash_reporter.zig index 2fdfb17394..f31ed81b65 100644 --- a/src/crash_reporter.zig +++ b/src/crash_reporter.zig @@ -46,7 +46,7 @@ pub fn reloadHandlers() !void { }; try setup_sigactions(&act); - + @import("root").bun.spawn.WaiterThread.reloadHandlers(); bun_ignore_sigpipe(); } const os = std.os; @@ -59,6 +59,7 @@ pub fn start() !void { try setup_sigactions(&act); bun_ignore_sigpipe(); + @import("root").bun.spawn.WaiterThread.reloadHandlers(); } extern fn bun_ignore_sigpipe() void;