1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-19 20:02:50 +00:00

Make os/execute on windows closer to posix version

This commit is contained in:
Calvin Rose 2019-05-31 15:02:44 -04:00
parent 1f30ea66e9
commit e1bd24c2ab

View File

@ -290,17 +290,26 @@ static Janet os_execute(int32_t argc, Janet *argv) {
/* Windows docs say do this before any spawns. */
_flushall();
if (flags & (JANET_OS_EFLAG_P | JANET_OS_EFLAG_E)) {
status = (int) _spawnvpe(_P_WAIT, path, cargv, envp);
/* Use an empty env instead when envp is NULL to be consistent with other implementation. */
char *empty_env[1] = {NULL};
char **envp1 = (NULL == envp) ? empty_env : envp;
if ((flags & JANET_OS_EFLAG_P) && (flags & JANET_OS_EFLAG_E)) {
status = (int) _spawnvpe(_P_WAIT, path, cargv, envp1);
} else if (flags & JANET_OS_EFLAG_P) {
status = (int) _spawnvp(_P_WAIT, path, cargv);
} else if (flags & JANET_OS_EFLAG_E) {
status = (int) _spawnve(_P_WAIT, path, cargv, envp);
status = (int) _spawnve(_P_WAIT, path, cargv, envp1);
} else {
status = (int) _spawnv(_P_WAIT, path, cargv);
}
os_execute_cleanup(envp, NULL);
/* Check error */
if (-1 == status) {
janet_panic(strerror(errno));
}
return janet_wrap_integer(status);
#else