X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udevd.c;h=a8328bbb81a60d2a093089d6490ddb8f7e58577b;hp=7ae7a5b232c7bd1264baa35e5ab091e6d927ac0b;hb=1e26698933e89c11dc6806d8bd37fd4386814239;hpb=c2cf40123f836b0f24da2604aba177b86b93823d diff --git a/udevd.c b/udevd.c index 7ae7a5b23..a8328bbb8 100644 --- a/udevd.c +++ b/udevd.c @@ -450,6 +450,7 @@ static void reap_sigchilds(void) static void user_sighandler(void) { int sig; + while(1) { int rc = read(pipefds[0], &sig, sizeof(sig)); if (rc < 0) @@ -500,6 +501,7 @@ int main(int argc, char *argv[], char *envp[]) int fd; struct sigaction act; fd_set readfds; + const char *udevd_expected_seqnum; logging_init("udevd"); dbg("version %s", UDEV_VERSION); @@ -533,15 +535,14 @@ int main(int argc, char *argv[], char *envp[]) /* Set fds to dev/null */ fd = open( "/dev/null", O_RDWR ); - if ( fd < 0 ) { + if (fd >= 0) { + dup2(fd, 0); + dup2(fd, 1); + dup2(fd, 2); + if (fd > 2) + close(fd); + } else dbg("error opening /dev/null %s", strerror(errno)); - goto exit; - } - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); - if (fd > 2) - close(fd); /* become session leader */ setsid(); @@ -559,10 +560,8 @@ int main(int argc, char *argv[], char *envp[]) goto exit; } retval = fcntl(pipefds[0], F_SETFD, FD_CLOEXEC); - if (retval < 0) { + if (retval < 0) dbg("error fcntl on read pipe: %s", strerror(errno)); - goto exit; - } retval = fcntl(pipefds[1], F_SETFL, O_NONBLOCK); if (retval < 0) { @@ -570,10 +569,8 @@ int main(int argc, char *argv[], char *envp[]) goto exit; } retval = fcntl(pipefds[1], F_SETFD, FD_CLOEXEC); - if (retval < 0) { + if (retval < 0) dbg("error fcntl on write pipe: %s", strerror(errno)); - goto exit; - } /* set signal handlers */ act.sa_handler = (void (*) (int))sig_handler; @@ -586,7 +583,7 @@ int main(int argc, char *argv[], char *envp[]) if (init_udevsend_socket() < 0) { if (errno == EADDRINUSE) - dbg("another udevd is running, exit"); + dbg("another udevd running, exit"); else dbg("error initialising udevsend socket: %s", strerror(errno)); @@ -600,7 +597,14 @@ int main(int argc, char *argv[], char *envp[]) else udev_bin = UDEV_BIN; - /* handle special startup timeout*/ + /* possible set of expected_seqnum number */ + udevd_expected_seqnum = getenv("UDEVD_EXPECTED_SEQNUM"); + if (udevd_expected_seqnum != NULL) { + expected_seqnum = strtoull(udevd_expected_seqnum, NULL, 10); + dbg("initialize expected_seqnum to %llu", expected_seqnum); + } + + /* get current time to provide shorter startup timeout */ sysinfo(&info); startup_time = info.uptime;