From a9117076131234e880815185592a19501ff5732d Mon Sep 17 00:00:00 2001 From: krzosa Date: Mon, 11 Aug 2025 08:41:29 +0200 Subject: [PATCH] Fix working dir when spawning process --- src/basic/unix.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/basic/unix.cpp b/src/basic/unix.cpp index 9320913..fe76be5 100644 --- a/src/basic/unix.cpp +++ b/src/basic/unix.cpp @@ -257,11 +257,17 @@ Array SplitCommand(Allocator allocator, String command_line) { } Process SpawnProcess(String command_line, String working_dir, String write_stdin, Array enviroment) { + Scratch scratch; const int PIPE_READ = 0; const int PIPE_WRITE = 1; bool error = false; - Scratch scratch; + char *buffer = AllocArray(scratch, char, 4096); + chdir(working_dir.data); + getcwd(buffer, 4096); + defer { chdir(buffer); }; + + Process process = {}; UnixProcess *plat = (UnixProcess *)&process.platform; Array args = SplitCommand(scratch, command_line);