diff options
author | Ron Yorston <rmy@pobox.com> | 2021-06-19 11:23:45 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-06-19 11:23:45 +0100 |
commit | 6d6856355aec9ed6c9b8039b9b1ec8f997395c9e (patch) | |
tree | d88afda6050d9d1ff6651f3fa1c6bb46ef26a84b | |
parent | 4b47d8fad2e48cb1d18e77479146d6c9ee130d41 (diff) | |
download | busybox-w32-6d6856355aec9ed6c9b8039b9b1ec8f997395c9e.tar.gz busybox-w32-6d6856355aec9ed6c9b8039b9b1ec8f997395c9e.tar.bz2 busybox-w32-6d6856355aec9ed6c9b8039b9b1ec8f997395c9e.zip |
win32: handle -1 return status from execve(2)
The implementations of execve(2) and execvp(3) were unable to
distinguish between failure and a program returning a status of -1.
Check the error return code to discriminate between these cases.
See GitHub issue #218.
-rw-r--r-- | win32/process.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/win32/process.c b/win32/process.c index 9e0740d6d..1b344f747 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -268,6 +268,7 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env) | |||
268 | new_path = xasprintf("%s.", path); | 268 | new_path = xasprintf("%s.", path); |
269 | } | 269 | } |
270 | 270 | ||
271 | errno = 0; | ||
271 | ret = spawnve(mode, new_path ? new_path : path, new_argv, env); | 272 | ret = spawnve(mode, new_path ? new_path : path, new_argv, env); |
272 | 273 | ||
273 | done: | 274 | done: |
@@ -404,7 +405,7 @@ int | |||
404 | mingw_execvp(const char *cmd, char *const *argv) | 405 | mingw_execvp(const char *cmd, char *const *argv) |
405 | { | 406 | { |
406 | int ret = (int)mingw_spawn_1(P_WAIT, cmd, argv, environ); | 407 | int ret = (int)mingw_spawn_1(P_WAIT, cmd, argv, environ); |
407 | if (ret != -1) | 408 | if (ret != -1 || errno == 0) |
408 | exit(ret); | 409 | exit(ret); |
409 | return ret; | 410 | return ret; |
410 | } | 411 | } |
@@ -413,7 +414,7 @@ int | |||
413 | mingw_execve(const char *cmd, char *const *argv, char *const *envp) | 414 | mingw_execve(const char *cmd, char *const *argv, char *const *envp) |
414 | { | 415 | { |
415 | int ret = (int)mingw_spawn_interpreter(P_WAIT, cmd, argv, envp, 0); | 416 | int ret = (int)mingw_spawn_interpreter(P_WAIT, cmd, argv, envp, 0); |
416 | if (ret != -1) | 417 | if (ret != -1 || errno == 0) |
417 | exit(ret); | 418 | exit(ret); |
418 | return ret; | 419 | return ret; |
419 | } | 420 | } |