[BusyBox-cvs] busybox/init init.c,1.197,1.198
Glenn McGrath
bug1 at busybox.net
Fri Sep 26 10:45:59 UTC 2003
Update of /var/cvs/busybox/init
In directory winder:/tmp/cvs-serv7883/init
Modified Files:
init.c
Log Message:
Patch by Guillaume Morin
Fix two race conditions, as described at.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=212764
Index: init.c
===================================================================
RCS file: /var/cvs/busybox/init/init.c,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -d -r1.197 -r1.198
--- init.c 15 Sep 2003 08:11:29 -0000 1.197
+++ init.c 26 Sep 2003 10:45:55 -0000 1.198
@@ -500,7 +500,12 @@
signal(SIGCHLD, SIG_DFL);
/* Wait for child to exit */
- while ((tmp_pid = waitpid(pid, &junk, 0)) != pid);
+ while ((tmp_pid = waitpid(pid, &junk, 0)) != pid) {
+ if (tmp_pid == -1 && errno == ECHILD) {
+ break;
+ }
+ /* FIXME handle other errors */
+ }
/* See if stealing the controlling tty back is necessary */
pgrp = tcgetpgrp(0);
@@ -624,12 +629,15 @@
pid = run(a);
while (1) {
- wpid = wait(&status);
- if (wpid > 0 && wpid != pid) {
- continue;
- }
+ wpid = waitpid(pid,&status,0);
if (wpid == pid)
break;
+ if (wpid == -1 && errno == ECHILD) {
+ /* we missed its termination */
+ break;
+ }
+ /* FIXME other errors should maybe trigger an error, but allow
+ * the program to continue */
}
return wpid;
}
More information about the busybox-cvs
mailing list