Since we don't want init to exit when we call udevadm, fork first. But before we do that, may as well wait for our forked udevd to exit, so there's some chance it's listening for connections. --- loader/init.c | 39 ++++++++++++++++++++++++++++++++------- 1 files changed, 32 insertions(+), 7 deletions(-) diff --git a/loader/init.c b/loader/init.c index 1b8c858..1505657 100644 --- a/loader/init.c +++ b/loader/init.c @@ -584,17 +584,42 @@ int main(int argc, char **argv) { printf("creating /dev filesystem... "); if (!testing) { + pid_t childpid; if (mount("/dev", "/dev", "tmpfs", 0, NULL)) fatal_error(1); createDevices(); printf("done\n"); - printf("starting udev..."); - if (fork() == 0) { - execl("/sbin/udevd", "/sbin/udevd","--daemon",NULL); - exit(1); - } - - execl("/sbin/udevadm", "udevadm", "control", "--env=ANACONDA=1", NULL); + printf("starting udev..."); + if ((childpid = fork()) == 0) { + execl("/sbin/udevd", "/sbin/udevd", "--daemon", NULL); + exit(1); + } + + /* wait at least until the udevd process that we forked exits */ + do { + pid_t retpid; + int waitstatus; + + retpid = waitpid(childpid, &waitstatus, 0); + if (retpid == -1) { + if (errno == EINTR) + continue; + /* if the child exited before we called waitpid, we can get + * ECHILD without anything really being wrong; we just lost + * the race.*/ + if (errno == ECHILD) + break; + printf("init: error waiting on udevd: %m\n"); + exit(1); + } else if (WIFEXITED(waitstatus)) { + break; + } + } while (1); + + if (fork() == 0) { + execl("/sbin/udevadm", "udevadm", "control", "--env=ANACONDA=1", NULL); + exit(1); + } } printf("done\n"); -- 1.6.5.rc2 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list