diff options
-rw-r--r-- | Config.in | 26 | ||||
-rw-r--r-- | include/libbb.h | 1 | ||||
-rw-r--r-- | libbb/xfuncs.c | 16 | ||||
-rw-r--r-- | modutils/modprobe.c | 23 |
4 files changed, 40 insertions, 26 deletions
@@ -32,6 +32,7 @@ config CONFIG_NITPICK | |||
32 | choice | 32 | choice |
33 | prompt "Buffer allocation policy" | 33 | prompt "Buffer allocation policy" |
34 | default CONFIG_FEATURE_BUFFERS_USE_MALLOC | 34 | default CONFIG_FEATURE_BUFFERS_USE_MALLOC |
35 | depends on CONFIG_NITPICK | ||
35 | help | 36 | help |
36 | There are 3 ways BusyBox can handle buffer allocations: | 37 | There are 3 ways BusyBox can handle buffer allocations: |
37 | - Use malloc. This costs code size for the call to xmalloc. | 38 | - Use malloc. This costs code size for the call to xmalloc. |
@@ -75,11 +76,17 @@ config CONFIG_FEATURE_VERBOSE_USAGE | |||
75 | config CONFIG_FEATURE_COMPRESS_USAGE | 76 | config CONFIG_FEATURE_COMPRESS_USAGE |
76 | bool "Store applet usage messages in compressed form" | 77 | bool "Store applet usage messages in compressed form" |
77 | default y | 78 | default y |
78 | depends on CONFIG_SHOW_USAGE | 79 | depends on CONFIG_SHOW_USAGE && CONFIG_NITPICK |
79 | help | 80 | help |
80 | Store usage messages in compressed form, uncompress them on-the-fly | 81 | Store usage messages in compressed form, uncompress them on-the-fly |
81 | when <applet> --help is called. | 82 | when <applet> --help is called. |
82 | 83 | ||
84 | If you have a really tiny busybox with few applets enabled (and | ||
85 | bunzip2 isn't one of them), the overhead of the decompressor might | ||
86 | be noticeable. Also, if you run executables directly from ROM | ||
87 | and have very little memory, this might not be a win. Otherwise, | ||
88 | you probably want this. | ||
89 | |||
83 | config CONFIG_FEATURE_INSTALLER | 90 | config CONFIG_FEATURE_INSTALLER |
84 | bool "Support --install [-s] to install applet links at runtime" | 91 | bool "Support --install [-s] to install applet links at runtime" |
85 | default n | 92 | default n |
@@ -99,14 +106,13 @@ config CONFIG_LOCALE_SUPPORT | |||
99 | config CONFIG_GETOPT_LONG | 106 | config CONFIG_GETOPT_LONG |
100 | bool "Enable support for --long-options" | 107 | bool "Enable support for --long-options" |
101 | default n | 108 | default n |
102 | depends on !CONFIG_NO_GETOPT_LONG | ||
103 | help | 109 | help |
104 | Enable this if you want busybox applets to use the gnu --long-option | 110 | Enable this if you want busybox applets to use the gnu --long-option |
105 | style, in addition to single character -a -b -c style options. | 111 | style, in addition to single character -a -b -c style options. |
106 | 112 | ||
107 | config CONFIG_FEATURE_DEVPTS | 113 | config CONFIG_FEATURE_DEVPTS |
108 | bool "Use the devpts filesystem for Unix98 PTYs" | 114 | bool "Use the devpts filesystem for Unix98 PTYs" |
109 | default y if CONFIG_FEATURE_DEVFS | 115 | default y |
110 | help | 116 | help |
111 | Enable if you want BusyBox to use Unix98 PTY support. If enabled, | 117 | Enable if you want BusyBox to use Unix98 PTY support. If enabled, |
112 | busybox will use /dev/ptmx for the master side of the pseudoterminal | 118 | busybox will use /dev/ptmx for the master side of the pseudoterminal |
@@ -117,6 +123,7 @@ config CONFIG_FEATURE_DEVPTS | |||
117 | config CONFIG_FEATURE_CLEAN_UP | 123 | config CONFIG_FEATURE_CLEAN_UP |
118 | bool "Clean up all memory before exiting (usually not needed)" | 124 | bool "Clean up all memory before exiting (usually not needed)" |
119 | default n | 125 | default n |
126 | depends on CONFIG_NITPICK | ||
120 | help | 127 | help |
121 | As a size optimization, busybox normally exits without explicitly | 128 | As a size optimization, busybox normally exits without explicitly |
122 | freeing dynamically allocated memory or closing files. This saves | 129 | freeing dynamically allocated memory or closing files. This saves |
@@ -201,6 +208,16 @@ config CONFIG_SELINUX | |||
201 | 208 | ||
202 | Most people will leave this set to 'N'. | 209 | Most people will leave this set to 'N'. |
203 | 210 | ||
211 | config CONFIG_BUSYBOX_EXEC_PATH | ||
212 | string "Path to BusyBox executable" | ||
213 | default "/proc/self/exe" | ||
214 | help | ||
215 | When Busybox applets need to run other busybox applets, BusyBox | ||
216 | sometimes needs to exec() itself. When the /proc filesystem is | ||
217 | mounted, /proc/self/exe always points to the currently running | ||
218 | executable. If you haven't got /proc, set this to wherever you | ||
219 | want to run BusyBox from. | ||
220 | |||
204 | endmenu | 221 | endmenu |
205 | 222 | ||
206 | menu 'Build Options' | 223 | menu 'Build Options' |
@@ -221,7 +238,8 @@ config CONFIG_STATIC | |||
221 | 238 | ||
222 | config CONFIG_BUILD_LIBBUSYBOX | 239 | config CONFIG_BUILD_LIBBUSYBOX |
223 | bool "Build shared libbusybox" | 240 | bool "Build shared libbusybox" |
224 | default y | 241 | depends on CONFIG_STANDALONE |
242 | default n | ||
225 | help | 243 | help |
226 | Build a shared library libbusybox.so which contains all | 244 | Build a shared library libbusybox.so which contains all |
227 | libraries used inside busybox. | 245 | libraries used inside busybox. |
diff --git a/include/libbb.h b/include/libbb.h index b93b7a618..5877a4a83 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -171,6 +171,7 @@ extern void xstat(const char *filename, struct stat *buf); | |||
171 | extern int bb_xsocket(int domain, int type, int protocol); | 171 | extern int bb_xsocket(int domain, int type, int protocol); |
172 | extern pid_t bb_spawn(char **argv); | 172 | extern pid_t bb_spawn(char **argv); |
173 | extern pid_t bb_xspawn(char **argv); | 173 | extern pid_t bb_xspawn(char **argv); |
174 | extern int wait4pid(int pid); | ||
174 | extern void bb_xdaemon(int nochdir, int noclose); | 175 | extern void bb_xdaemon(int nochdir, int noclose); |
175 | extern void bb_xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); | 176 | extern void bb_xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); |
176 | extern void bb_xlisten(int s, int backlog); | 177 | extern void bb_xlisten(int s, int backlog); |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 2cfafb01a..432fd6079 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include <sys/types.h> | 10 | #include <sys/types.h> |
11 | #include <sys/stat.h> | 11 | #include <sys/stat.h> |
12 | #include <sys/wait.h> | ||
12 | #include <stdio.h> | 13 | #include <stdio.h> |
13 | #include <string.h> | 14 | #include <string.h> |
14 | #include <stdlib.h> | 15 | #include <stdlib.h> |
@@ -189,13 +190,14 @@ pid_t bb_spawn(char **argv) | |||
189 | { | 190 | { |
190 | static int failed; | 191 | static int failed; |
191 | pid_t pid; | 192 | pid_t pid; |
193 | void *app = find_applet_by_name(argv[0]); | ||
192 | 194 | ||
193 | // Be nice to nommu machines. | 195 | // Be nice to nommu machines. |
194 | failed = 0; | 196 | failed = 0; |
195 | pid = vfork(); | 197 | pid = vfork(); |
196 | if (pid < 0) return pid; | 198 | if (pid < 0) return pid; |
197 | if (!pid) { | 199 | if (!pid) { |
198 | execvp(*argv, argv); | 200 | execvp(app ? CONFIG_BUSYBOX_EXEC_PATH : *argv, argv); |
199 | 201 | ||
200 | // We're sharing a stack with blocked parent, let parent know we failed | 202 | // We're sharing a stack with blocked parent, let parent know we failed |
201 | // and then exit to unblock parent (but don't run atexit() stuff, which | 203 | // and then exit to unblock parent (but don't run atexit() stuff, which |
@@ -216,3 +218,15 @@ pid_t bb_xspawn(char **argv) | |||
216 | return pid; | 218 | return pid; |
217 | } | 219 | } |
218 | #endif | 220 | #endif |
221 | |||
222 | #ifdef L_wait4 | ||
223 | int wait4pid(int pid) | ||
224 | { | ||
225 | int status; | ||
226 | |||
227 | if (pid == -1 || waitpid(pid, &status, 0) == -1) return -1; | ||
228 | if (WIFEXITED(status)) return WEXITSTATUS(status); | ||
229 | if (WIFSIGNALED(status)) return WTERMSIG(status); | ||
230 | return 0; | ||
231 | } | ||
232 | #endif | ||
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 93e510293..698eed84a 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -666,27 +666,8 @@ static int mod_process ( struct mod_list_t *list, int do_insert ) | |||
666 | printf("%s module %s\n", do_insert?"Loading":"Unloading", list-> m_name ); | 666 | printf("%s module %s\n", do_insert?"Loading":"Unloading", list-> m_name ); |
667 | } | 667 | } |
668 | if (!show_only) { | 668 | if (!show_only) { |
669 | int rc2 = 0; | 669 | int rc2 = wait4pid(bb_spawn(argv)); |
670 | int status; | 670 | |
671 | switch (fork()) { | ||
672 | case -1: | ||
673 | rc2 = 1; | ||
674 | break; | ||
675 | case 0: //child | ||
676 | execvp(argv[0], argv); | ||
677 | bb_perror_msg_and_die("exec of %s", argv[0]); | ||
678 | /* NOTREACHED */ | ||
679 | default: | ||
680 | if (wait(&status) == -1) { | ||
681 | rc2 = 1; | ||
682 | break; | ||
683 | } | ||
684 | if (WIFEXITED(status)) | ||
685 | rc2 = WEXITSTATUS(status); | ||
686 | if (WIFSIGNALED(status)) | ||
687 | rc2 = WTERMSIG(status); | ||
688 | break; | ||
689 | } | ||
690 | if (do_insert) { | 671 | if (do_insert) { |
691 | rc = rc2; /* only last module matters */ | 672 | rc = rc2; /* only last module matters */ |
692 | } | 673 | } |