diff options
Diffstat (limited to 'runtime/daemon.zig')
| -rw-r--r-- | runtime/daemon.zig | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/runtime/daemon.zig b/runtime/daemon.zig index 595d5107..97941a12 100644 --- a/runtime/daemon.zig +++ b/runtime/daemon.zig @@ -241,9 +241,8 @@ extern "c" fn close_range(first: c_uint, last: c_uint, flags: c_int) c_int; /// twice), on the listener and the lock as fds 3 and 4. fn spawn(listener: c_int, lock: c_int) bool { var exe_buf: [4096:0]u8 = undefined; - const n = std.process.executablePath(std.Io.Threaded.global_single_threaded.io(), &exe_buf) catch return false; - exe_buf[n] = 0; - const argv = [_:null]?[*:0]const u8{ &exe_buf, "--daemon", null }; + const exe = upgrade.startPath(&exe_buf) orelse return false; + const argv = [_:null]?[*:0]const u8{ exe, "--daemon", null }; const first = libc.fork(); if (first < 0) return false; if (first == 0) { @@ -268,7 +267,7 @@ fn spawn(listener: c_int, lock: c_int) bool { }; if (null_fd > 4) _ = libc.close(null_fd); _ = libc.chdir("/"); - _ = libc.execve(&exe_buf, &argv, @ptrCast(libc.environ)); + _ = libc.execve(exe, &argv, @ptrCast(libc.environ)); libc._exit(127); } var status: c_int = 0; @@ -677,8 +676,13 @@ fn stubWait(session: libc.pid_t, pipe: c_int) noreturn { if (libc.W.IFEXITED(s)) libc._exit(@intCast(libc.W.EXITSTATUS(s))); if (libc.W.IFSIGNALED(s)) { const sig = libc.W.TERMSIG(s); - const default: posix.Sigaction = .{ .handler = .{ .handler = posix.SIG.DFL }, .mask = posix.sigemptyset(), .flags = 0 }; - posix.sigaction(sig, &default, null); + // A KILL's action is its default already and cannot be set + // (EINVAL: posix.sigaction's unreachable, the stub aborting with a + // trace on the terminal); any other is put back to it first. + if (sig != .KILL) { + const default: posix.Sigaction = .{ .handler = .{ .handler = posix.SIG.DFL }, .mask = posix.sigemptyset(), .flags = 0 }; + posix.sigaction(sig, &default, null); + } _ = libc.raise(sig); } libc._exit(1); |
