diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-23 00:49:10 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-23 00:49:10 +0000 |
commit | 8f6c79240dc7c1e0b819a1a1309240477d8e0d84 (patch) | |
tree | 79b9cc0ea2e0077dc8e78c1adc6a61c6992becba | |
parent | 4cccc03768ecde58e8acd5e4f40e51227e3c14cc (diff) | |
download | busybox-w32-8f6c79240dc7c1e0b819a1a1309240477d8e0d84.tar.gz busybox-w32-8f6c79240dc7c1e0b819a1a1309240477d8e0d84.tar.bz2 busybox-w32-8f6c79240dc7c1e0b819a1a1309240477d8e0d84.zip |
find: fix spurious -exec error messages
(bug reported by Bernhard Fischer <rep.nop@aon.at>)
-rw-r--r-- | findutils/find.c | 3 | ||||
-rw-r--r-- | libbb/xfuncs.c | 9 |
2 files changed, 8 insertions, 4 deletions
diff --git a/findutils/find.c b/findutils/find.c index bf6b71a83..38bbfbec9 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
@@ -197,9 +197,8 @@ ACTF(exec) | |||
197 | for (i = 0; i < ap->exec_argc; i++) | 197 | for (i = 0; i < ap->exec_argc; i++) |
198 | argv[i] = subst(ap->exec_argv[i], ap->subst_count[i], fileName); | 198 | argv[i] = subst(ap->exec_argv[i], ap->subst_count[i], fileName); |
199 | argv[i] = NULL; /* terminate the list */ | 199 | argv[i] = NULL; /* terminate the list */ |
200 | errno = 0; | ||
201 | rc = wait4pid(spawn(argv)); | 200 | rc = wait4pid(spawn(argv)); |
202 | if (errno) | 201 | if (rc) |
203 | bb_perror_msg("%s", argv[0]); | 202 | bb_perror_msg("%s", argv[0]); |
204 | for (i = 0; i < ap->exec_argc; i++) | 203 | for (i = 0; i < ap->exec_argc; i++) |
205 | free(argv[i]); | 204 | free(argv[i]); |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 9efccc542..136dd1cca 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -181,6 +181,7 @@ void xfflush_stdout(void) | |||
181 | // -1 for failure. Runs argv[0], searching path if that has no / in it. | 181 | // -1 for failure. Runs argv[0], searching path if that has no / in it. |
182 | pid_t spawn(char **argv) | 182 | pid_t spawn(char **argv) |
183 | { | 183 | { |
184 | /* Why static? */ | ||
184 | static int failed; | 185 | static int failed; |
185 | pid_t pid; | 186 | pid_t pid; |
186 | void *app = ENABLE_FEATURE_SH_STANDALONE_SHELL ? find_applet_by_name(argv[0]) : 0; | 187 | void *app = ENABLE_FEATURE_SH_STANDALONE_SHELL ? find_applet_by_name(argv[0]) : 0; |
@@ -196,10 +197,14 @@ pid_t spawn(char **argv) | |||
196 | // and then exit to unblock parent (but don't run atexit() stuff, which | 197 | // and then exit to unblock parent (but don't run atexit() stuff, which |
197 | // would screw up parent.) | 198 | // would screw up parent.) |
198 | 199 | ||
199 | failed = -1; | 200 | failed = errno; |
200 | _exit(0); | 201 | _exit(0); |
201 | } | 202 | } |
202 | return failed ? failed : pid; | 203 | if (failed) { |
204 | errno = failed; | ||
205 | return -1; | ||
206 | } | ||
207 | return pid; | ||
203 | } | 208 | } |
204 | 209 | ||
205 | // Die with an error message if we can't spawn a child process. | 210 | // Die with an error message if we can't spawn a child process. |