aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-07-12 12:16:05 +0200
committerIsaac Freund <ifreund@ifreund.xyz>2020-07-12 12:16:05 +0200
commitf3d4e5ac5311f27d8b17f2797a861aab4bae5673 (patch)
tree8dfc9aa2397c7b131bd838a793072d4da99c9a0d
parent8120829e5ca0bdd055b7437d43e9aa9285082d2b (diff)
downloadriver-f3d4e5ac5311f27d8b17f2797a861aab4bae5673.tar.gz
river-f3d4e5ac5311f27d8b17f2797a861aab4bae5673.tar.xz
command/spawn: use _exit(2) instead of exit(3)
Something in exit(3) is causing the intermediate fork to segfault.
-rw-r--r--river/command/spawn.zig10
1 files changed, 6 insertions, 4 deletions
diff --git a/river/command/spawn.zig b/river/command/spawn.zig
index fdc3ccb..8e1bdfe 100644
--- a/river/command/spawn.zig
+++ b/river/command/spawn.zig
@@ -48,15 +48,17 @@ pub fn spawn(
if (c.setsid() < 0) unreachable;
if (std.os.system.sigprocmask(std.os.SIG_SETMASK, &std.os.empty_sigset, null) < 0) unreachable;
- const pid2 = std.os.fork() catch std.os.exit(1);
- if (pid2 == 0) std.os.execveZ("/bin/sh", &child_args, std.c.environ) catch std.os.exit(1);
+ const pid2 = std.os.fork() catch c._exit(1);
+ if (pid2 == 0) std.os.execveZ("/bin/sh", &child_args, std.c.environ) catch c._exit(1);
- std.os.exit(0);
+ c._exit(0);
}
// Wait the intermediate child.
const status = std.os.waitpid(pid, 0);
- if (std.os.WIFEXITED(status) and std.os.WEXITSTATUS(status) != 0) {
+ if (!std.os.WIFEXITED(status) or
+ (std.os.WIFEXITED(status) and std.os.WEXITSTATUS(status) != 0))
+ {
out.* = try std.fmt.allocPrint(allocator, "fork/execve failed", .{});
return Error.Other;
}