1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: implement Process.set_work_folder/0 to set the initial working folder of the new child process (#17946)

This commit is contained in:
Delyan Angelov
2023-04-13 14:48:32 +03:00
committed by GitHub
parent 489ac892b9
commit c6947fde57
5 changed files with 90 additions and 7 deletions

View File

@ -50,6 +50,15 @@ fn (mut p Process) unix_spawn_process() int {
fd_close(pipeset[3])
fd_close(pipeset[5])
}
if p.work_folder != '' {
if !is_abs_path(p.filename) {
// Ensure p.filename contains an absolute path, so it
// can be located reliably, even after changing the
// current folder in the child process:
p.filename = abs_path(p.filename)
}
chdir(p.work_folder) or {}
}
execve(p.filename, p.args, p.env) or {
eprintln(err)
exit(1)