Child of fork calls this to report an error to the fork parent. Then the child exits.
fn forkBail(fd: posix.fd_t, err: ForkBailError) noreturn
fn forkBail(fd: posix.fd_t, err: ForkBailError) noreturn {
writeIntFd(fd, @as(ErrInt, @intFromError(err))) catch {};
// If we're linking libc, some naughty applications may have registered atexit handlers
// which we really do not want to run in the fork child. I caught LLVM doing this and
// it caused a deadlock instead of doing an exit syscall. In the words of Avril Lavigne,
// "Why'd you have to go and make things so complicated?"
if (builtin.link_libc) {
// The `_exit` function does nothing but make the exit syscall, unlike `exit`.
std.c._exit(1);
} else if (native_os == .linux and !builtin.single_threaded) {
std.os.linux.exit_group(1);
} else {
posix.system.exit(1);
}
}