runsvdir: make it more robust against libc buglets (errno accidentally set to !0)
closes bug 3514 function old new delta runsvdir_main 1672 1664 -8
This commit is contained in:
@ -141,8 +141,12 @@ static void runsvdir(void)
|
|||||||
}
|
}
|
||||||
for (i = 0; i < svnum; i++)
|
for (i = 0; i < svnum; i++)
|
||||||
sv[i].isgone = 1;
|
sv[i].isgone = 1;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
while ((d = readdir(dir))) {
|
d = readdir(dir);
|
||||||
|
if (!d)
|
||||||
|
break;
|
||||||
if (d->d_name[0] == '.')
|
if (d->d_name[0] == '.')
|
||||||
continue;
|
continue;
|
||||||
if (stat(d->d_name, &s) == -1) {
|
if (stat(d->d_name, &s) == -1) {
|
||||||
@ -194,6 +198,7 @@ static void runsvdir(void)
|
|||||||
if (sv[i].pid)
|
if (sv[i].pid)
|
||||||
kill(sv[i].pid, SIGTERM);
|
kill(sv[i].pid, SIGTERM);
|
||||||
sv[i] = sv[--svnum];
|
sv[i] = sv[--svnum];
|
||||||
|
/* BUG? we deleted sv[i] by copying over sv[last], but we will not check this newly-copied one! */
|
||||||
check = 1;
|
check = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user