[BusyBox] Problem with process accounting

Vladimir N. Oleynik dzo at simtreas.ru
Wed Nov 20 08:18:03 UTC 2002


Michael,
 
> I've noticed in `ps` output that one particular
> process is shown only until its last slash, i.e.
> instead of /opt/BOS/test.out its /opt/BOS
> I've checked in its /proc/xxx directory and
> in "cmdline" there is a '\0' in place of last
> slash !!
> 
> I'm using 2.4.18 kernel and latest BusyBox.
> 
> Who is responsible for updating appropriate
> /proc directory when a process starts ?

Ok. Current and previous version ps have this problem.
But regular 'ps' util do not change from your example
'\0' to '/', only to ' '. 
Your program have bug from generator short program name.



--w
vodz
-------------- next part --------------
diff -rbu busybox.orig/libbb/procps.c busybox/libbb/procps.c
--- busybox.orig/libbb/procps.c	Sat Oct 19 18:31:48 2002
+++ busybox/libbb/procps.c	Wed Nov 20 18:04:45 2002
@@ -111,9 +111,16 @@
 		if(save_user_arg0) {
 			if((fp = fopen(status, "r")) == NULL)
 				continue;
-			if(fgets(buf, sizeof(buf), fp) != NULL) {
-				name = strchr(buf, '\n');
-				if(name != NULL)
+			if((n=fread(buf, 1, sizeof(buf)-1, fp)) > 0) {
+				if(buf[n-1]=='\n')
+					buf[--n] = 0;
+				name = buf;
+				while(n) {
+					if(*name < ' ')
+						*name = ' ';
+					name++;
+					n--;
+				}
 					*name = 0;
 				if(buf[0])
 					curstatus.cmd = strdup(buf);


More information about the busybox mailing list