Fix working dir when spawning process
This commit is contained in:
@@ -257,11 +257,17 @@ Array<char *> SplitCommand(Allocator allocator, String command_line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Process SpawnProcess(String command_line, String working_dir, String write_stdin, Array<String> enviroment) {
|
Process SpawnProcess(String command_line, String working_dir, String write_stdin, Array<String> enviroment) {
|
||||||
|
Scratch scratch;
|
||||||
const int PIPE_READ = 0;
|
const int PIPE_READ = 0;
|
||||||
const int PIPE_WRITE = 1;
|
const int PIPE_WRITE = 1;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
Scratch scratch;
|
char *buffer = AllocArray(scratch, char, 4096);
|
||||||
|
chdir(working_dir.data);
|
||||||
|
getcwd(buffer, 4096);
|
||||||
|
defer { chdir(buffer); };
|
||||||
|
|
||||||
|
|
||||||
Process process = {};
|
Process process = {};
|
||||||
UnixProcess *plat = (UnixProcess *)&process.platform;
|
UnixProcess *plat = (UnixProcess *)&process.platform;
|
||||||
Array<char *> args = SplitCommand(scratch, command_line);
|
Array<char *> args = SplitCommand(scratch, command_line);
|
||||||
|
|||||||
Reference in New Issue
Block a user