svn commit: trunk/busybox/debianutils

vda at busybox.net vda at busybox.net
Sat Apr 19 20:19:46 UTC 2008


Author: vda
Date: 2008-04-19 13:19:45 -0700 (Sat, 19 Apr 2008)
New Revision: 21776

Log:
start_stop_daemon: do not stop /proc scan prematurely

function                                             old     new   delta
do_procinit                                          185     196     +11



Modified:
   trunk/busybox/debianutils/start_stop_daemon.c


Changeset:
Modified: trunk/busybox/debianutils/start_stop_daemon.c
===================================================================
--- trunk/busybox/debianutils/start_stop_daemon.c	2008-04-19 19:32:08 UTC (rev 21775)
+++ trunk/busybox/debianutils/start_stop_daemon.c	2008-04-19 20:19:45 UTC (rev 21776)
@@ -145,11 +145,18 @@
 	procdir = xopendir("/proc");
 
 	pid = 0;
-	while ((entry = readdir(procdir)) != NULL) {
-		pid = bb_strtou(entry->d_name, NULL, 10);
-		if (errno)
-			continue;
-		check(pid);
+ 	while(1) {
+ 		errno = 0; /* clear any previous error */
+ 		entry = readdir(procdir);
+// TODO: check for exact errno(s) which mean that we got stale entry
+ 		if (errno) /* Stale entry, process has died after opendir */
+  			continue;
+ 		if (!entry) /* EOF, no more entries */
+ 			break;
+ 		pid = bb_strtou(entry->d_name, NULL, 10);
+ 		if (errno) /* NaN */
+ 			continue;
+  		check(pid);
 	}
 	closedir(procdir);
 	if (!pid)




More information about the busybox-cvs mailing list