diff options
author | Denis Vlasenko | 2007-04-09 13:04:50 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-04-09 13:04:50 +0000 |
commit | 7e754f12d304704d44e10fd4d2fdb8710526656e (patch) | |
tree | 9aa16703d48b9a7a38ccaec3759a19e95e976383 /findutils/find.c | |
parent | 2dfdd44d9d6c3984501683bbac2e78b18eeae1e7 (diff) | |
download | busybox-7e754f12d304704d44e10fd4d2fdb8710526656e.zip busybox-7e754f12d304704d44e10fd4d2fdb8710526656e.tar.gz |
Implement first instance of NOFORK applet - echo
find: use NOFORK/NOEXEC; small -exec buglet also eliminated
vfork_daemon_rexec: honor PREFER_APPLETS
echo: small size improvements
find -exec echo {} \; with PREFER_APPLETS=y runs 4 times faster
Diffstat (limited to 'findutils/find.c')
-rw-r--r-- | findutils/find.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/findutils/find.c b/findutils/find.c index 594eafc..7b5a09d 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -242,9 +242,30 @@ ACTF(exec) 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 */ - rc = wait4pid(spawn(argv)); - if (rc) + + 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); + 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 */ |