diff options
| author | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-09-26 10:45:55 +0000 |
|---|---|---|
| committer | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-09-26 10:45:55 +0000 |
| commit | aaa01deb98105d78c4ecd3bc194914b454f40a67 (patch) | |
| tree | e124c339f514c556442e4bce82a6fd62c768e33a | |
| parent | 38bc00cd979a3c702254ce4290ea4751f46a15f9 (diff) | |
| download | busybox-w32-aaa01deb98105d78c4ecd3bc194914b454f40a67.tar.gz busybox-w32-aaa01deb98105d78c4ecd3bc194914b454f40a67.tar.bz2 busybox-w32-aaa01deb98105d78c4ecd3bc194914b454f40a67.zip | |
Patch by Guillaume Morin
Fix two race conditions, as described at.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=212764
git-svn-id: svn://busybox.net/trunk/busybox@7567 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -rw-r--r-- | init/init.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/init/init.c b/init/init.c index 85792c9b7..d332ccdbe 100644 --- a/init/init.c +++ b/init/init.c | |||
| @@ -500,7 +500,12 @@ static pid_t run(const struct init_action *a) | |||
| 500 | signal(SIGCHLD, SIG_DFL); | 500 | signal(SIGCHLD, SIG_DFL); |
| 501 | 501 | ||
| 502 | /* Wait for child to exit */ | 502 | /* Wait for child to exit */ |
| 503 | while ((tmp_pid = waitpid(pid, &junk, 0)) != pid); | 503 | while ((tmp_pid = waitpid(pid, &junk, 0)) != pid) { |
| 504 | if (tmp_pid == -1 && errno == ECHILD) { | ||
| 505 | break; | ||
| 506 | } | ||
| 507 | /* FIXME handle other errors */ | ||
| 508 | } | ||
| 504 | 509 | ||
| 505 | /* See if stealing the controlling tty back is necessary */ | 510 | /* See if stealing the controlling tty back is necessary */ |
| 506 | pgrp = tcgetpgrp(0); | 511 | pgrp = tcgetpgrp(0); |
| @@ -624,12 +629,15 @@ static int waitfor(const struct init_action *a) | |||
| 624 | 629 | ||
| 625 | pid = run(a); | 630 | pid = run(a); |
| 626 | while (1) { | 631 | while (1) { |
| 627 | wpid = wait(&status); | 632 | wpid = waitpid(pid,&status,0); |
| 628 | if (wpid > 0 && wpid != pid) { | ||
| 629 | continue; | ||
| 630 | } | ||
| 631 | if (wpid == pid) | 633 | if (wpid == pid) |
| 632 | break; | 634 | break; |
| 635 | if (wpid == -1 && errno == ECHILD) { | ||
| 636 | /* we missed its termination */ | ||
| 637 | break; | ||
| 638 | } | ||
| 639 | /* FIXME other errors should maybe trigger an error, but allow | ||
| 640 | * the program to continue */ | ||
| 633 | } | 641 | } |
| 634 | return wpid; | 642 | return wpid; |
| 635 | } | 643 | } |
