mirror of
https://git.robbyzambito.me/zaprus
synced 2026-02-04 00:14:52 +00:00
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:
31
src/main.zig
31
src/main.zig
@@ -178,7 +178,36 @@ pub fn main(init: std.process.Init) !void {
|
|||||||
.stdout = .pipe,
|
.stdout = .pipe,
|
||||||
.stderr = .ignore,
|
.stderr = .ignore,
|
||||||
.stdin = .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_buf: [SaprusClient.max_payload_len]u8 = undefined;
|
||||||
var child_output_reader = child.stdout.?.reader(init.io, &child_output_buf);
|
var child_output_reader = child.stdout.?.reader(init.io, &child_output_buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user