find: fix spurious -exec error messages
(bug reported by Bernhard Fischer <rep.nop@aon.at>)
This commit is contained in:
@@ -197,9 +197,8 @@ ACTF(exec)
|
|||||||
for (i = 0; i < ap->exec_argc; i++)
|
for (i = 0; i < ap->exec_argc; i++)
|
||||||
argv[i] = subst(ap->exec_argv[i], ap->subst_count[i], fileName);
|
argv[i] = subst(ap->exec_argv[i], ap->subst_count[i], fileName);
|
||||||
argv[i] = NULL; /* terminate the list */
|
argv[i] = NULL; /* terminate the list */
|
||||||
errno = 0;
|
|
||||||
rc = wait4pid(spawn(argv));
|
rc = wait4pid(spawn(argv));
|
||||||
if (errno)
|
if (rc)
|
||||||
bb_perror_msg("%s", argv[0]);
|
bb_perror_msg("%s", argv[0]);
|
||||||
for (i = 0; i < ap->exec_argc; i++)
|
for (i = 0; i < ap->exec_argc; i++)
|
||||||
free(argv[i]);
|
free(argv[i]);
|
||||||
|
@@ -181,6 +181,7 @@ void xfflush_stdout(void)
|
|||||||
// -1 for failure. Runs argv[0], searching path if that has no / in it.
|
// -1 for failure. Runs argv[0], searching path if that has no / in it.
|
||||||
pid_t spawn(char **argv)
|
pid_t spawn(char **argv)
|
||||||
{
|
{
|
||||||
|
/* Why static? */
|
||||||
static int failed;
|
static int failed;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
void *app = ENABLE_FEATURE_SH_STANDALONE_SHELL ? find_applet_by_name(argv[0]) : 0;
|
void *app = ENABLE_FEATURE_SH_STANDALONE_SHELL ? find_applet_by_name(argv[0]) : 0;
|
||||||
@@ -196,10 +197,14 @@ pid_t spawn(char **argv)
|
|||||||
// and then exit to unblock parent (but don't run atexit() stuff, which
|
// and then exit to unblock parent (but don't run atexit() stuff, which
|
||||||
// would screw up parent.)
|
// would screw up parent.)
|
||||||
|
|
||||||
failed = -1;
|
failed = errno;
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
return failed ? failed : pid;
|
if (failed) {
|
||||||
|
errno = failed;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Die with an error message if we can't spawn a child process.
|
// Die with an error message if we can't spawn a child process.
|
||||||
|
Reference in New Issue
Block a user