mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 03:48:56 +00:00
Use _exit but restore stdio on error
This commit is contained in:
@@ -95,10 +95,11 @@ export fn Bun__atexit(function: ExitFn) void {
|
||||
}
|
||||
|
||||
pub fn runExitCallbacks() void {
|
||||
for (on_exit_callbacks.items) |callback| {
|
||||
const callbacks = on_exit_callbacks.items;
|
||||
on_exit_callbacks.items.len = 0;
|
||||
for (callbacks) |callback| {
|
||||
callback();
|
||||
}
|
||||
on_exit_callbacks.items.len = 0;
|
||||
}
|
||||
|
||||
var is_exiting = std.atomic.Value(bool).init(false);
|
||||
@@ -116,6 +117,11 @@ pub fn exit(code: u32) noreturn {
|
||||
// If we are crashing, allow the crash handler to finish it's work.
|
||||
bun.crash_handler.sleepForeverIfAnotherThreadIsCrashing();
|
||||
|
||||
if (code != 0) {
|
||||
Bun__onExit();
|
||||
std._exit(@bitCast(code));
|
||||
}
|
||||
|
||||
switch (Environment.os) {
|
||||
.mac => std.c.exit(@bitCast(code)),
|
||||
else => bun.C.quick_exit(@bitCast(code)),
|
||||
|
||||
Reference in New Issue
Block a user