Using BB_EXECVP ensures consistency with spawn() function,
and allows moving NOEXEC support to BB_EXECVP, which makes
BB_EXECVP to go-to function for running new processes.
Signed-off-by: Nadav Tasher <tasherna...@gmail.com>
---
 libbb/vfork_daemon_rexec.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index 2055c4b71..43f09f2f1 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -225,26 +225,27 @@ pid_t FAST_FUNC xspawn(char **argv)
 int FAST_FUNC spawn_and_wait(char **argv)
 {
        int rc;
-#if ENABLE_FEATURE_PREFER_APPLETS && (NUM_APPLETS > 1)
+#if ENABLE_FEATURE_PREFER_APPLETS && (NUM_APPLETS > 1) && NOFORK_SUPPORT
        int a = find_applet_by_name(argv[0]);
 
        if (a >= 0) {
                if (APPLET_IS_NOFORK(a))
                        return run_nofork_applet(a, argv);
-# if BB_MMU /* NOEXEC needs fork(), thus this is done only on MMU machines: */
-               if (APPLET_IS_NOEXEC(a)) {
-                       fflush_all();
-                       rc = fork();
-                       if (rc) /* parent or error */
-                               return wait4pid(rc);
-
-                       /* child */
-                       run_noexec_applet_and_exit(a, argv[0], argv);
-               }
-# endif
        }
 #endif
+#if BB_MMU /* fork() only allowd on MMU machines */
+       fflush_all();
+       rc = fork();
+
+       /* child */
+       if (rc == 0)
+               BB_EXECVP_or_die(argv);
+#else /* !BB_MMU */
+       /* one call, (v)fork()->BB_EXECVP */
        rc = spawn(argv);
+#endif
+
+       /* parent or error */
        return wait4pid(rc);
 }
 
-- 
2.43.0

_______________________________________________
busybox mailing list
busybox@busybox.net
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to