Exec command directly if subshell fails

If execing the child fails, it might be because the shell doesn't exist.
Try running the command directly before giving up.
This commit is contained in:
2026-01-31 20:29:34 -05:00
parent 4f721afcfd
commit daf18d3552

View File

@@ -178,7 +178,36 @@ pub fn main(init: std.process.Init) !void {
.stdout = .pipe,
.stderr = .ignore,
.stdin = .ignore,
}) catch continue;
}) catch |err| switch (err) {
error.AccessDenied,
error.FileBusy,
error.FileNotFound,
error.FileSystem,
error.InvalidExe,
error.IsDir,
error.NotDir,
error.OutOfMemory,
error.PermissionDenied,
error.SymLinkLoop,
error.SystemResources,
=> blk: {
var argv_buf: [128][]const u8 = undefined;
var argv: ArrayList([]const u8) = .initBuffer(&argv_buf);
var payload_iter = std.mem.splitAny(u8, connection_payload, " \t\n");
while (payload_iter.next()) |arg| argv.appendBounded(arg) catch continue;
break :blk std.process.spawn(init.io, .{
.argv = argv.items,
.stdout = .pipe,
.stderr = .ignore,
.stdin = .ignore,
}) catch continue;
},
error.Canceled,
error.NoDevice,
error.OperationUnsupported,
=> |e| return e,
else => continue,
};
var child_output_buf: [SaprusClient.max_payload_len]u8 = undefined;
var child_output_reader = child.stdout.?.reader(init.io, &child_output_buf);