summaryrefslogtreecommitdiff
path: root/src/daemon.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon.zig')
-rw-r--r--src/daemon.zig4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/daemon.zig b/src/daemon.zig
index bc9e9773..6c0a0adf 100644
--- a/src/daemon.zig
+++ b/src/daemon.zig
@@ -247,7 +247,9 @@ fn spawn(listener: c_int, lock: c_int) bool {
const l = libc.fcntl(listener, libc.F.DUPFD, @as(c_int, 10));
const k = libc.fcntl(lock, libc.F.DUPFD, @as(c_int, 10));
if (l < 0 or k < 0 or libc.dup2(l, 3) < 0 or libc.dup2(k, 4) < 0) libc._exit(127);
- if (close_range(5, std.math.maxInt(c_uint), 0) != 0) {
+ // Linux's by its syscall: musl (a static pardes) has no close_range.
+ const shut = if (comptime builtin.os.tag == .linux) std.os.linux.close_range(5, std.math.maxInt(i32), .{ .UNSHARE = false, .CLOEXEC = false }) == 0 else close_range(5, std.math.maxInt(c_uint), 0) == 0;
+ if (!shut) {
var fd: c_int = 5;
while (fd < 1024) : (fd += 1) _ = libc.close(fd);
}