diff options
author | Ron Yorston <rmy@pobox.com> | 2016-05-17 08:29:14 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-05-18 08:43:42 +0100 |
commit | 4988f3c4cc3cb9e8b1ccb06e84768c177cb13385 (patch) | |
tree | 06f4b1b13ffab2c9ceb278d9d6e5b7caad2d2355 | |
parent | 864141a5cc9c52b0cbed7e248b846af42ce70162 (diff) | |
download | busybox-w32-4988f3c4cc3cb9e8b1ccb06e84768c177cb13385.tar.gz busybox-w32-4988f3c4cc3cb9e8b1ccb06e84768c177cb13385.tar.bz2 busybox-w32-4988f3c4cc3cb9e8b1ccb06e84768c177cb13385.zip |
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.
-rw-r--r-- | include/mingw.h | 2 | ||||
-rw-r--r-- | shell/ash.c | 3 | ||||
-rw-r--r-- | 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); | |||
453 | int mingw_execv(const char *cmd, const char *const *argv); | 453 | int mingw_execv(const char *cmd, const char *const *argv); |
454 | int mingw_execvp(const char *cmd, const char *const *argv); | 454 | int mingw_execvp(const char *cmd, const char *const *argv); |
455 | int mingw_execve(const char *cmd, const char *const *argv, const char *const *envp); | 455 | int mingw_execve(const char *cmd, const char *const *argv, const char *const *envp); |
456 | pid_t mingw_spawn_applet(int mode, const char *applet, const char *const *argv, const char *const *envp); | ||
457 | pid_t mingw_spawn_1(int mode, const char *cmd, const char *const *argv, const char *const *envp); | ||
458 | #define spawn mingw_spawn | 456 | #define spawn mingw_spawn |
459 | #define execvp mingw_execvp | 457 | #define execvp mingw_execvp |
460 | #define execve mingw_execve | 458 | #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) | |||
14005 | new = forkshell_prepare(fs); | 14005 | new = forkshell_prepare(fs); |
14006 | sprintf(buf, "%x", (unsigned int)new->hMapFile); | 14006 | sprintf(buf, "%x", (unsigned int)new->hMapFile); |
14007 | argv[2] = buf; | 14007 | argv[2] = buf; |
14008 | pid = mingw_spawn_applet(P_NOWAIT, "sh", argv, | 14008 | pid = spawn(argv); |
14009 | (const char *const *)environ); | ||
14010 | CloseHandle(new->hMapFile); | 14009 | CloseHandle(new->hMapFile); |
14011 | UnmapViewOfFile(new); | 14010 | UnmapViewOfFile(new); |
14012 | if (pid == -1) { | 14011 | 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 @@ | |||
4 | int waitpid(pid_t pid, int *status, int options) | 4 | int waitpid(pid_t pid, int *status, int options) |
5 | { | 5 | { |
6 | HANDLE proc; | 6 | HANDLE proc; |
7 | int ret; | 7 | intptr_t ret; |
8 | 8 | ||
9 | /* Windows does not understand parent-child */ | 9 | /* Windows does not understand parent-child */ |
10 | if (pid > 0 && options == 0) { | 10 | if (pid > 0 && options == 0) { |
@@ -12,7 +12,7 @@ int waitpid(pid_t pid, int *status, int options) | |||
12 | FALSE, pid)) != NULL ) { | 12 | FALSE, pid)) != NULL ) { |
13 | ret = _cwait(status, (intptr_t)proc, 0); | 13 | ret = _cwait(status, (intptr_t)proc, 0); |
14 | CloseHandle(proc); | 14 | CloseHandle(proc); |
15 | return ret; | 15 | return ret == -1 ? -1 : pid; |
16 | } | 16 | } |
17 | } | 17 | } |
18 | errno = EINVAL; | 18 | errno = EINVAL; |
@@ -207,12 +207,12 @@ quote_arg(const char *arg) | |||
207 | return q; | 207 | return q; |
208 | } | 208 | } |
209 | 209 | ||
210 | static pid_t | 210 | static intptr_t |
211 | spawnveq(int mode, const char *path, const char *const *argv, const char *const *env) | 211 | spawnveq(int mode, const char *path, const char *const *argv, const char *const *env) |
212 | { | 212 | { |
213 | char **new_argv; | 213 | char **new_argv; |
214 | int i, argc = 0; | 214 | int i, argc = 0; |
215 | pid_t ret; | 215 | intptr_t ret; |
216 | 216 | ||
217 | if (!argv) { | 217 | if (!argv) { |
218 | const char *empty_argv[] = { path, NULL }; | 218 | const char *empty_argv[] = { path, NULL }; |
@@ -235,7 +235,7 @@ spawnveq(int mode, const char *path, const char *const *argv, const char *const | |||
235 | return ret; | 235 | return ret; |
236 | } | 236 | } |
237 | 237 | ||
238 | pid_t | 238 | static intptr_t |
239 | mingw_spawn_applet(int mode, | 239 | mingw_spawn_applet(int mode, |
240 | const char *applet, | 240 | const char *applet, |
241 | const char *const *argv, | 241 | const char *const *argv, |
@@ -243,7 +243,7 @@ mingw_spawn_applet(int mode, | |||
243 | { | 243 | { |
244 | char **env = copy_environ(envp); | 244 | char **env = copy_environ(envp); |
245 | char path[MAX_PATH+20]; | 245 | char path[MAX_PATH+20]; |
246 | int ret; | 246 | intptr_t ret; |
247 | 247 | ||
248 | sprintf(path, "BUSYBOX_APPLET_NAME=%s", applet); | 248 | sprintf(path, "BUSYBOX_APPLET_NAME=%s", applet); |
249 | env = env_setenv(env, path); | 249 | env = env_setenv(env, path); |
@@ -252,10 +252,10 @@ mingw_spawn_applet(int mode, | |||
252 | return ret; | 252 | return ret; |
253 | } | 253 | } |
254 | 254 | ||
255 | static pid_t | 255 | static intptr_t |
256 | mingw_spawn_interpreter(int mode, const char *prog, const char *const *argv, const char *const *envp) | 256 | mingw_spawn_interpreter(int mode, const char *prog, const char *const *argv, const char *const *envp) |
257 | { | 257 | { |
258 | int ret; | 258 | intptr_t ret; |
259 | char **opts; | 259 | char **opts; |
260 | int nopts; | 260 | int nopts; |
261 | const char *interpr = parse_interpreter(prog, &opts, &nopts); | 261 | 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 | |||
296 | return ret; | 296 | return ret; |
297 | } | 297 | } |
298 | 298 | ||
299 | pid_t | 299 | static intptr_t |
300 | mingw_spawn_1(int mode, const char *cmd, const char *const *argv, const char *const *envp) | 300 | mingw_spawn_1(int mode, const char *cmd, const char *const *argv, const char *const *envp) |
301 | { | 301 | { |
302 | int ret; | 302 | intptr_t ret; |
303 | 303 | ||
304 | if (ENABLE_FEATURE_PREFER_APPLETS && | 304 | if (ENABLE_FEATURE_PREFER_APPLETS && |
305 | find_applet_by_name(cmd) >= 0) | 305 | find_applet_by_name(cmd) >= 0) |