From 4988f3c4cc3cb9e8b1ccb06e84768c177cb13385 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 17 May 2016 08:29:14 +0100 Subject: win32: adjustments to spawn functions Make mingw_spawn_applet and mingw_spawn_1 static. The return value from spawnve is an exit code in synchronous mode and a process handle in asynchronous mode. Pass these upwards without interpretation. --- include/mingw.h | 2 -- shell/ash.c | 3 +-- win32/process.c | 20 ++++++++++---------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/include/mingw.h b/include/mingw.h index 555fa96b7..bfdf2cccd 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -453,8 +453,6 @@ pid_t FAST_FUNC mingw_spawn(char **argv); int mingw_execv(const char *cmd, const char *const *argv); int mingw_execvp(const char *cmd, const char *const *argv); int mingw_execve(const char *cmd, const char *const *argv, const char *const *envp); -pid_t mingw_spawn_applet(int mode, const char *applet, const char *const *argv, const char *const *envp); -pid_t mingw_spawn_1(int mode, const char *cmd, const char *const *argv, const char *const *envp); #define spawn mingw_spawn #define execvp mingw_execvp #define execve mingw_execve diff --git a/shell/ash.c b/shell/ash.c index 5870a23f3..340115c35 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -14005,8 +14005,7 @@ spawn_forkshell(struct job *jp, struct forkshell *fs, int mode) new = forkshell_prepare(fs); sprintf(buf, "%x", (unsigned int)new->hMapFile); argv[2] = buf; - pid = mingw_spawn_applet(P_NOWAIT, "sh", argv, - (const char *const *)environ); + pid = spawn(argv); CloseHandle(new->hMapFile); UnmapViewOfFile(new); if (pid == -1) { diff --git a/win32/process.c b/win32/process.c index 951519e59..8cd1dc28c 100644 --- a/win32/process.c +++ b/win32/process.c @@ -4,7 +4,7 @@ int waitpid(pid_t pid, int *status, int options) { HANDLE proc; - int ret; + intptr_t ret; /* Windows does not understand parent-child */ if (pid > 0 && options == 0) { @@ -12,7 +12,7 @@ int waitpid(pid_t pid, int *status, int options) FALSE, pid)) != NULL ) { ret = _cwait(status, (intptr_t)proc, 0); CloseHandle(proc); - return ret; + return ret == -1 ? -1 : pid; } } errno = EINVAL; @@ -207,12 +207,12 @@ quote_arg(const char *arg) return q; } -static pid_t +static intptr_t spawnveq(int mode, const char *path, const char *const *argv, const char *const *env) { char **new_argv; int i, argc = 0; - pid_t ret; + intptr_t ret; if (!argv) { const char *empty_argv[] = { path, NULL }; @@ -235,7 +235,7 @@ spawnveq(int mode, const char *path, const char *const *argv, const char *const return ret; } -pid_t +static intptr_t mingw_spawn_applet(int mode, const char *applet, const char *const *argv, @@ -243,7 +243,7 @@ mingw_spawn_applet(int mode, { char **env = copy_environ(envp); char path[MAX_PATH+20]; - int ret; + intptr_t ret; sprintf(path, "BUSYBOX_APPLET_NAME=%s", applet); env = env_setenv(env, path); @@ -252,10 +252,10 @@ mingw_spawn_applet(int mode, return ret; } -static pid_t +static intptr_t mingw_spawn_interpreter(int mode, const char *prog, const char *const *argv, const char *const *envp) { - int ret; + intptr_t ret; char **opts; int nopts; const char *interpr = parse_interpreter(prog, &opts, &nopts); @@ -296,10 +296,10 @@ mingw_spawn_interpreter(int mode, const char *prog, const char *const *argv, con return ret; } -pid_t +static intptr_t mingw_spawn_1(int mode, const char *cmd, const char *const *argv, const char *const *envp) { - int ret; + intptr_t ret; if (ENABLE_FEATURE_PREFER_APPLETS && find_applet_by_name(cmd) >= 0) -- cgit v1.2.3-55-g6feb