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.
This commit is contained in:
parent
304d72fc6f
commit
eb42f25a4e
|
@ -9413,7 +9413,7 @@ static char *cmdline_protect(char *s)
|
||||||
static intptr_t mz_spawnv(char *command, const char * const *argv,
|
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 exact_cmdline, intptr_t sin, intptr_t sout, intptr_t serr, int *pid,
|
||||||
int new_process_group,
|
int new_process_group,
|
||||||
void *env)
|
void *env, char *wd)
|
||||||
{
|
{
|
||||||
int i, l, len = 0;
|
int i, l, len = 0;
|
||||||
intptr_t cr_flag;
|
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),
|
if (CreateProcessW(WIDE_PATH_COPY(command), WIDE_PATH_COPY(cmdline),
|
||||||
NULL, NULL, 1 /*inherit*/,
|
NULL, NULL, 1 /*inherit*/,
|
||||||
cr_flag, env, NULL,
|
cr_flag, env, WIDE_PATH_COPY(wd),
|
||||||
&startup, &info)) {
|
&startup, &info)) {
|
||||||
CloseHandle(info.hThread);
|
CloseHandle(info.hThread);
|
||||||
*pid = info.dwProcessId;
|
*pid = info.dwProcessId;
|
||||||
|
@ -9772,9 +9772,7 @@ static Scheme_Object *subprocess(int c, Scheme_Object *args[])
|
||||||
|
|
||||||
config = scheme_current_config();
|
config = scheme_current_config();
|
||||||
|
|
||||||
/* Set real CWD before spawn: */
|
|
||||||
tcd = scheme_get_param(config, MZCONFIG_CURRENT_DIRECTORY);
|
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);
|
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],
|
err_subprocess[1],
|
||||||
&pid,
|
&pid,
|
||||||
new_process_group,
|
new_process_group,
|
||||||
env);
|
env, SCHEME_BYTE_STR_VAL(tcd));
|
||||||
|
|
||||||
if (spawn_status != -1)
|
if (spawn_status != -1)
|
||||||
sc = (void *)spawn_status;
|
sc = (void *)spawn_status;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user