aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-05-31 07:00:33 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-05-31 07:00:33 +0000
commit8f74094548a1147ed7b459ca771343483b1c202c (patch)
tree2c43fc4d181a71cb4c9a25cd520cb8367c6e85a6
parent447bd6683729eb6d0f09e30eb68add6297881d01 (diff)
downloadbusybox-w32-8f74094548a1147ed7b459ca771343483b1c202c.tar.gz
busybox-w32-8f74094548a1147ed7b459ca771343483b1c202c.tar.bz2
busybox-w32-8f74094548a1147ed7b459ca771343483b1c202c.zip
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
-rw-r--r--runit/runsvdir.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/runit/runsvdir.c b/runit/runsvdir.c
index b4450c00c..df6b8869d 100644
--- a/runit/runsvdir.c
+++ b/runit/runsvdir.c
@@ -141,8 +141,12 @@ static void runsvdir(void)
141 } 141 }
142 for (i = 0; i < svnum; i++) 142 for (i = 0; i < svnum; i++)
143 sv[i].isgone = 1; 143 sv[i].isgone = 1;
144 errno = 0; 144
145 while ((d = readdir(dir))) { 145 while (1) {
146 errno = 0;
147 d = readdir(dir);
148 if (!d)
149 break;
146 if (d->d_name[0] == '.') 150 if (d->d_name[0] == '.')
147 continue; 151 continue;
148 if (stat(d->d_name, &s) == -1) { 152 if (stat(d->d_name, &s) == -1) {
@@ -194,6 +198,7 @@ static void runsvdir(void)
194 if (sv[i].pid) 198 if (sv[i].pid)
195 kill(sv[i].pid, SIGTERM); 199 kill(sv[i].pid, SIGTERM);
196 sv[i] = sv[--svnum]; 200 sv[i] = sv[--svnum];
201/* BUG? we deleted sv[i] by copying over sv[last], but we will not check this newly-copied one! */
197 check = 1; 202 check = 1;
198 } 203 }
199} 204}