[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [BusyBox] [PATCH] small pidof output fix
From:       Jim Treadway <jim () stardot-tech ! com>
Date:       2002-03-21 19:45:03
[Download RAW message or body]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic