[BusyBox] [PATCH] small pidof output fix

Jim Treadway jim at stardot-tech.com
Thu Mar 21 19:45:03 UTC 2002


The following patch (against busybox.stable) removes the leading space in
the output of from the "pidof" applet (so "cat /proc/`pidof foo`/status"
and similar works).

Jim


--- ./pidof.c.orig	Thu Mar 21 18:36:58 2002
+++ ./pidof.c	Thu Mar 21 18:40:02 2002
@@ -35,8 +35,7 @@
 
 extern int pidof_main(int argc, char **argv)
 {
-	int opt;
-
+	int opt, n = 0;
 
 	/* do normal option parsing */
 	while ((opt = getopt(argc, argv, "ne:f:")) > 0) {
@@ -66,7 +65,7 @@
 		}
 
 		for(; pidList && *pidList!=0; pidList++) {
-			printf("%ld ", (long)*pidList);
+			printf("%s%ld", (n++ ? " " : ""), (long)*pidList);
 		}
 		/* Note that we don't bother to free the memory
 		 * allocated in find_pid_by_name().  It will be freed




More information about the busybox mailing list