summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-12-08 19:03:12 +0000
committerEric Andersen <andersen@codepoet.org>2000-12-08 19:03:12 +0000
commit5e09b6e3a83c83fe3db99ef9f8b2cdf6dc21cec4 (patch)
treefca52cc08e30b0c0884add1e1413da9c730d82ff
parentf3b2b52b589bccae28b1740c155733028f2b8fd5 (diff)
downloadbusybox-w32-5e09b6e3a83c83fe3db99ef9f8b2cdf6dc21cec4.tar.gz
busybox-w32-5e09b6e3a83c83fe3db99ef9f8b2cdf6dc21cec4.tar.bz2
busybox-w32-5e09b6e3a83c83fe3db99ef9f8b2cdf6dc21cec4.zip
when invoked as 'busybox foo args' remove the "busybox"
so ps shows only what we want it to show...
-rw-r--r--applets/busybox.c29
-rw-r--r--busybox.c29
2 files changed, 50 insertions, 8 deletions
diff --git a/applets/busybox.c b/applets/busybox.c
index 212d46742..c8c060be7 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -126,8 +126,6 @@ int main(int argc, char **argv)
126 applet_name = s; 126 applet_name = s;
127 } 127 }
128 128
129 *argv = (char*)applet_name;
130
131#ifdef BB_SH 129#ifdef BB_SH
132 /* Add in a special case hack -- whenever **argv == '-' 130 /* Add in a special case hack -- whenever **argv == '-'
133 * (i.e. '-su' or '-sh') always invoke the shell */ 131 * (i.e. '-su' or '-sh') always invoke the shell */
@@ -153,10 +151,12 @@ int main(int argc, char **argv)
153int busybox_main(int argc, char **argv) 151int busybox_main(int argc, char **argv)
154{ 152{
155 int col = 0; 153 int col = 0;
154 int ps_index;
155 char *index, *index2;
156 156
157 argc--; 157 argc--;
158 argv++;
159 158
159 /* If we've already been here once, exit now */
160 if (been_there_done_that == 1 || argc < 1) { 160 if (been_there_done_that == 1 || argc < 1) {
161 const struct BB_applet *a = applets; 161 const struct BB_applet *a = applets;
162 162
@@ -181,8 +181,29 @@ int busybox_main(int argc, char **argv)
181 fprintf(stderr, "\n\n"); 181 fprintf(stderr, "\n\n");
182 exit(-1); 182 exit(-1);
183 } 183 }
184 /* If we've already been here once, exit now */ 184
185 /* Flag that we've been here already */
185 been_there_done_that = 1; 186 been_there_done_that = 1;
187
188 /* We do not want the word "busybox" to show up in ps, so we move
189 * everything in argv around to fake ps into showing what we want it to
190 * show. Since we are only shrinking the string, we don't need to move
191 * __environ or any of that tedious stuff... */
192 ps_index = 0;
193 index=*argv;
194 index2=argv[argc];
195 index2+=strlen(argv[argc]);
196 while(ps_index < argc) {
197 argv[ps_index]=index;
198 memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
199 index+=(strlen(index));
200 *index='\0';
201 index++;
202 ps_index++;
203 }
204 while(index<=index2)
205 *index++='\0';
206
186 return (main(argc, argv)); 207 return (main(argc, argv));
187} 208}
188 209
diff --git a/busybox.c b/busybox.c
index 212d46742..c8c060be7 100644
--- a/busybox.c
+++ b/busybox.c
@@ -126,8 +126,6 @@ int main(int argc, char **argv)
126 applet_name = s; 126 applet_name = s;
127 } 127 }
128 128
129 *argv = (char*)applet_name;
130
131#ifdef BB_SH 129#ifdef BB_SH
132 /* Add in a special case hack -- whenever **argv == '-' 130 /* Add in a special case hack -- whenever **argv == '-'
133 * (i.e. '-su' or '-sh') always invoke the shell */ 131 * (i.e. '-su' or '-sh') always invoke the shell */
@@ -153,10 +151,12 @@ int main(int argc, char **argv)
153int busybox_main(int argc, char **argv) 151int busybox_main(int argc, char **argv)
154{ 152{
155 int col = 0; 153 int col = 0;
154 int ps_index;
155 char *index, *index2;
156 156
157 argc--; 157 argc--;
158 argv++;
159 158
159 /* If we've already been here once, exit now */
160 if (been_there_done_that == 1 || argc < 1) { 160 if (been_there_done_that == 1 || argc < 1) {
161 const struct BB_applet *a = applets; 161 const struct BB_applet *a = applets;
162 162
@@ -181,8 +181,29 @@ int busybox_main(int argc, char **argv)
181 fprintf(stderr, "\n\n"); 181 fprintf(stderr, "\n\n");
182 exit(-1); 182 exit(-1);
183 } 183 }
184 /* If we've already been here once, exit now */ 184
185 /* Flag that we've been here already */
185 been_there_done_that = 1; 186 been_there_done_that = 1;
187
188 /* We do not want the word "busybox" to show up in ps, so we move
189 * everything in argv around to fake ps into showing what we want it to
190 * show. Since we are only shrinking the string, we don't need to move
191 * __environ or any of that tedious stuff... */
192 ps_index = 0;
193 index=*argv;
194 index2=argv[argc];
195 index2+=strlen(argv[argc]);
196 while(ps_index < argc) {
197 argv[ps_index]=index;
198 memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
199 index+=(strlen(index));
200 *index='\0';
201 index++;
202 ps_index++;
203 }
204 while(index<=index2)
205 *index++='\0';
206
186 return (main(argc, argv)); 207 return (main(argc, argv));
187} 208}
188 209