diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-09 13:04:50 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-09 13:04:50 +0000 |
| commit | 7e754f12d304704d44e10fd4d2fdb8710526656e (patch) | |
| tree | 9aa16703d48b9a7a38ccaec3759a19e95e976383 /findutils | |
| parent | 2dfdd44d9d6c3984501683bbac2e78b18eeae1e7 (diff) | |
| download | busybox-w32-7e754f12d304704d44e10fd4d2fdb8710526656e.tar.gz busybox-w32-7e754f12d304704d44e10fd4d2fdb8710526656e.tar.bz2 busybox-w32-7e754f12d304704d44e10fd4d2fdb8710526656e.zip | |
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')
| -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 594eafca4..7b5a09d56 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
| @@ -242,9 +242,30 @@ ACTF(exec) | |||
| 242 | for (i = 0; i < ap->exec_argc; i++) | 242 | for (i = 0; i < ap->exec_argc; i++) |
| 243 | argv[i] = subst(ap->exec_argv[i], ap->subst_count[i], fileName); | 243 | argv[i] = subst(ap->exec_argv[i], ap->subst_count[i], fileName); |
| 244 | argv[i] = NULL; /* terminate the list */ | 244 | argv[i] = NULL; /* terminate the list */ |
| 245 | rc = wait4pid(spawn(argv)); | 245 | |
| 246 | if (rc) | 246 | if (ENABLE_FEATURE_EXEC_PREFER_APPLETS) { |
| 247 | const struct BB_applet *a = find_applet_by_name(argv[0]); | ||
| 248 | if (a) { | ||
| 249 | if (a->nofork) { | ||
| 250 | rc = a->main(ap->exec_argc, argv); | ||
| 251 | goto f; | ||
| 252 | } | ||
| 253 | #ifndef BB_NOMMU | ||
| 254 | if (a->noexec) { | ||
| 255 | rc = fork(); | ||
| 256 | if (rc) goto w; | ||
| 257 | current_applet = a; | ||
| 258 | run_current_applet_and_exit(ap->exec_argc, argv); | ||
| 259 | } | ||
| 260 | #endif | ||
| 261 | } | ||
| 262 | } | ||
| 263 | rc = spawn(argv); | ||
| 264 | w: | ||
| 265 | rc = wait4pid(rc); | ||
| 266 | if (rc < 0) | ||
| 247 | bb_perror_msg("%s", argv[0]); | 267 | bb_perror_msg("%s", argv[0]); |
| 268 | f: | ||
| 248 | for (i = 0; i < ap->exec_argc; i++) | 269 | for (i = 0; i < ap->exec_argc; i++) |
| 249 | free(argv[i]); | 270 | free(argv[i]); |
| 250 | return rc == 0; /* return 1 if success */ | 271 | return rc == 0; /* return 1 if success */ |
