Hello, I’m new to Zig and Ziggit.
I am building a toy project to open other programs (in my case I’m using Explorer to open the current directory the binary is in). When I run the binary/exe it seems to work perfectly fine, but there seems to be an error that pops up on the terminal. It seems to only be getting the error when it invokes the spawnAndWait()
function from std.ChildProcess
. I’m pretty lost right now, is there something I’m doing wrong?
// test_me.zig
const std = @import("std");
const process = std.process;
const ChildProcess = std.ChildProcess;
pub fn main() !void {
const allocator = std.heap.page_allocator;
var child_proc = ChildProcess.init(&.{ "explorer", "." }, allocator);
var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const cwd = try process.getCwd(&buffer);
child_proc.cwd = cwd;
const proc_term = try child_proc.spawnAndWait();
switch (proc_term) {
.Exited => |code| {
if (code != 0) {
std.debug.print("Error!!! {d}\n", .{code});
@panic("OH NOOOOO!!!\n");
}
},
else => unreachable,
}
}
I’m compiling it on my Ubuntu WSL by running:
zig build-exe -target x86_64-windows test_me.zig
And after running the exe, it successfully opens Explorer in the current directory, but the terminal gives this error:
Sorry if this was asked before, but I can only find questions that are similar to mine but not exactly a solution. Anyways, thanks for the help