start_stop_daemon: do not stop /proc scan prematurely

function                                             old     new   delta
do_procinit                                          185     196     +11
This commit is contained in:
Denis Vlasenko 2008-04-19 20:19:45 +00:00
parent f3745ea489
commit daeddee442

View File

@ -145,11 +145,18 @@ static void do_procinit(void)
procdir = xopendir("/proc"); procdir = xopendir("/proc");
pid = 0; pid = 0;
while ((entry = readdir(procdir)) != NULL) { while(1) {
pid = bb_strtou(entry->d_name, NULL, 10); errno = 0; /* clear any previous error */
if (errno) entry = readdir(procdir);
continue; // TODO: check for exact errno(s) which mean that we got stale entry
check(pid); 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); closedir(procdir);
if (!pid) if (!pid)