aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/appletlib.c16
-rw-r--r--libbb/vfork_daemon_rexec.c33
2 files changed, 24 insertions, 25 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 5b84920a4..cbca7ef17 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -34,14 +34,6 @@
34# include <malloc.h> /* for mallopt */ 34# include <malloc.h> /* for mallopt */
35#endif 35#endif
36 36
37#include <sys/prctl.h>
38#ifndef PR_SET_NAME
39#define PR_SET_NAME 15
40#endif
41#ifndef PR_GET_NAME
42#define PR_GET_NAME 16
43#endif
44
45/* Declare <applet>_main() */ 37/* Declare <applet>_main() */
46#define PROTOTYPES 38#define PROTOTYPES
47#include "applets.h" 39#include "applets.h"
@@ -911,14 +903,6 @@ int busybox_main(int argc UNUSED_PARAM, char **argv)
911} 903}
912# endif 904# endif
913 905
914#if defined(__linux__) && (NUM_APPLETS > 1)
915void FAST_FUNC set_task_comm(const char *comm)
916{
917 /* okay if too long (truncates) */
918 prctl(PR_SET_NAME, (long)comm, 0, 0, 0);
919}
920#endif
921
922# if NUM_APPLETS > 0 906# if NUM_APPLETS > 0
923void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv) 907void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv)
924{ 908{
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index c96cd61a5..e55847f93 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -14,14 +14,32 @@
14 * 14 *
15 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 15 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
16 */ 16 */
17#include <sys/prctl.h>
18#ifndef PR_SET_NAME
19#define PR_SET_NAME 15
20#endif
21#ifndef PR_GET_NAME
22#define PR_GET_NAME 16
23#endif
24
17#include "busybox.h" /* uses applet tables */ 25#include "busybox.h" /* uses applet tables */
18#include "NUM_APPLETS.h" 26#include "NUM_APPLETS.h"
19 27
28#define NOFORK_SUPPORT ((NUM_APPLETS > 1) && (ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_NOFORK))
29#define NOEXEC_SUPPORT ((NUM_APPLETS > 1) && (ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE))
30
31#if defined(__linux__) && (NUM_APPLETS > 1)
32void FAST_FUNC set_task_comm(const char *comm)
33{
34 /* okay if too long (truncates) */
35 prctl(PR_SET_NAME, (long)comm, 0, 0, 0);
36}
37#endif
38
20/* 39/*
21 * NOFORK support 40 * NOFORK/NOEXEC support
22 */ 41 */
23#if ENABLE_FEATURE_PREFER_APPLETS \ 42#if NOFORK_SUPPORT
24 || ENABLE_FEATURE_SH_NOFORK
25static jmp_buf die_jmp; 43static jmp_buf die_jmp;
26static void jump(void) 44static void jump(void)
27{ 45{
@@ -109,12 +127,9 @@ int FAST_FUNC run_nofork_applet(int applet_no, char **argv)
109 127
110 return rc & 0xff; /* don't confuse people with "exitcodes" >255 */ 128 return rc & 0xff; /* don't confuse people with "exitcodes" >255 */
111} 129}
112#endif /* FEATURE_PREFER_APPLETS || FEATURE_SH_NOFORK */ 130#endif
113 131
114/* 132#if NOEXEC_SUPPORT
115 * NOEXEC support
116 */
117#if (NUM_APPLETS > 1) && (ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE)
118void FAST_FUNC run_noexec_applet_and_exit(int a, const char *name, char **argv) 133void FAST_FUNC run_noexec_applet_and_exit(int a, const char *name, char **argv)
119{ 134{
120 /* reset some state and run without execing */ 135 /* reset some state and run without execing */
@@ -212,7 +227,7 @@ int FAST_FUNC spawn_and_wait(char **argv)
212 } 227 }
213# endif 228# endif
214 } 229 }
215#endif /* FEATURE_PREFER_APPLETS */ 230#endif
216 rc = spawn(argv); 231 rc = spawn(argv);
217 return wait4pid(rc); 232 return wait4pid(rc);
218} 233}