diff options
author | Denis Vlasenko | 2007-04-09 21:32:30 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-04-09 21:32:30 +0000 |
commit | cd7001f7055c3fc2d6298ab9e3befe91e951c652 (patch) | |
tree | b9509ed21e0a7af26128b796a66a3294ae4dc5b0 /findutils/find.c | |
parent | 1b4b2cb20e5291c319ce0c7721e64445e2749b10 (diff) | |
download | busybox-cd7001f7055c3fc2d6298ab9e3befe91e951c652.zip busybox-cd7001f7055c3fc2d6298ab9e3befe91e951c652.tar.gz |
factor out NOFORK/NOEXEC code from find. Use it for xargs too.
Diffstat (limited to 'findutils/find.c')
-rw-r--r-- | findutils/find.c | 32 |
1 files changed, 7 insertions, 25 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 |