summaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
Diffstat (limited to 'findutils')
-rw-r--r--findutils/find.c32
-rw-r--r--findutils/xargs.c35
2 files changed, 17 insertions, 50 deletions
diff --git a/findutils/find.c b/findutils/find.c
index 7b5a09d..1a1301b 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -238,37 +238,19 @@ ACTF(inum)
ACTF(exec)
{
int i, rc;
- char *argv[ap->exec_argc+1];
+ char *argv[ap->exec_argc + 1];
for (i = 0; i < ap->exec_argc; i++)
argv[i] = subst(ap->exec_argv[i], ap->subst_count[i], fileName);
argv[i] = NULL; /* terminate the list */
- if (ENABLE_FEATURE_EXEC_PREFER_APPLETS) {
- const struct BB_applet *a = find_applet_by_name(argv[0]);
- if (a) {
- if (a->nofork) {
- rc = a->main(ap->exec_argc, argv);
- goto f;
- }
-#ifndef BB_NOMMU
- if (a->noexec) {
- rc = fork();
- if (rc) goto w;
- current_applet = a;
- run_current_applet_and_exit(ap->exec_argc, argv);
- }
-#endif
- }
- }
- rc = spawn(argv);
- w:
- rc = wait4pid(rc);
+ rc = spawn_and_wait(argv);
if (rc < 0)
bb_perror_msg("%s", argv[0]);
- f:
- for (i = 0; i < ap->exec_argc; i++)
- free(argv[i]);
- return rc == 0; /* return 1 if success */
+
+ i = 0;
+ while (argv[i])
+ free(argv[i++]);
+ return rc == 0; /* return 1 if exitcode 0 */
}
#endif
diff --git a/findutils/xargs.c b/findutils/xargs.c
index ea7c220..b4dd9f8 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -48,47 +48,32 @@
This function has special algorithm.
Don't use fork and include to main!
*/
-static int xargs_exec(char *const *args)
+static int xargs_exec(char **args)
{
- pid_t p;
- volatile int exec_errno = 0; /* shared vfork stack */
int status;
- p = vfork();
- if (p < 0)
- bb_perror_msg_and_die("vfork");
-
- if (p == 0) {
- /* vfork -- child */
- BB_EXECVP(args[0], args);
- exec_errno = errno; /* set error to shared stack */
- _exit(1);
- }
-
- /* vfork -- parent */
- while (wait(&status) == (pid_t) -1)
- if (errno != EINTR)
- break;
- if (exec_errno) {
- errno = exec_errno;
+ status = spawn_and_wait(args);
+ if (status < 0) {
bb_perror_msg("%s", args[0]);
- return exec_errno == ENOENT ? 127 : 126;
+ return errno == ENOENT ? 127 : 126;
}
- if (WEXITSTATUS(status) == 255) {
+ if (status == 255) {
bb_error_msg("%s: exited with status 255; aborting", args[0]);
return 124;
}
+/* Huh? I think we won't see this, ever. We don't wait with WUNTRACED!
if (WIFSTOPPED(status)) {
bb_error_msg("%s: stopped by signal %d",
args[0], WSTOPSIG(status));
return 125;
}
- if (WIFSIGNALED(status)) {
+*/
+ if (status >= 1000) {
bb_error_msg("%s: terminated by signal %d",
- args[0], WTERMSIG(status));
+ args[0], status - 1000);
return 125;
}
- if (WEXITSTATUS(status))
+ if (status)
return 123;
return 0;
}