From eb42f25a4ebc5da1a54122d475144c286fdf3e9b Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 14 Oct 2013 21:11:11 -0600 Subject: [PATCH] Windows: pass current directory CreateProcess instead of setting Avoids races setting/using a process-wide current directory, and avoids locking the directory that was most recently used to start a subprocess. --- racket/src/racket/src/port.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/racket/src/racket/src/port.c b/racket/src/racket/src/port.c index d0a3b73539..f2a1811f73 100644 --- a/racket/src/racket/src/port.c +++ b/racket/src/racket/src/port.c @@ -9413,7 +9413,7 @@ static char *cmdline_protect(char *s) static intptr_t mz_spawnv(char *command, const char * const *argv, int exact_cmdline, intptr_t sin, intptr_t sout, intptr_t serr, int *pid, int new_process_group, - void *env) + void *env, char *wd) { int i, l, len = 0; intptr_t cr_flag; @@ -9462,7 +9462,7 @@ static intptr_t mz_spawnv(char *command, const char * const *argv, if (CreateProcessW(WIDE_PATH_COPY(command), WIDE_PATH_COPY(cmdline), NULL, NULL, 1 /*inherit*/, - cr_flag, env, NULL, + cr_flag, env, WIDE_PATH_COPY(wd), &startup, &info)) { CloseHandle(info.hThread); *pid = info.dwProcessId; @@ -9772,9 +9772,7 @@ static Scheme_Object *subprocess(int c, Scheme_Object *args[]) config = scheme_current_config(); - /* Set real CWD before spawn: */ tcd = scheme_get_param(config, MZCONFIG_CURRENT_DIRECTORY); - scheme_os_setcwd(SCHEME_BYTE_STR_VAL(tcd), 0); envvar = scheme_get_param(config, MZCONFIG_CURRENT_ENV_VARS); @@ -9787,7 +9785,7 @@ static Scheme_Object *subprocess(int c, Scheme_Object *args[]) err_subprocess[1], &pid, new_process_group, - env); + env, SCHEME_BYTE_STR_VAL(tcd)); if (spawn_status != -1) sc = (void *)spawn_status;