chiark / gitweb /
udevd: init signal pipe before daemonizing
authorSergey Vlasov <vsu@altlinux.ru>
Sun, 21 Jan 2007 21:51:53 +0000 (22:51 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Sun, 21 Jan 2007 21:51:53 +0000 (22:51 +0100)
udevd.c

diff --git a/udevd.c b/udevd.c
index 79465a1da08afe289f4d3b1ba3c4487ff06f8bde..8c550d38aa3b8f2154c2fc0a073ac75811d6476d 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -1006,6 +1006,35 @@ int main(int argc, char *argv[], char *envp[])
                goto exit;
        }
 
+       /* setup signal handler pipe */
+       retval = pipe(signal_pipe);
+       if (retval < 0) {
+               err("error getting pipes: %s", strerror(errno));
+               goto exit;
+       }
+
+       retval = fcntl(signal_pipe[READ_END], F_GETFL, 0);
+       if (retval < 0) {
+               err("error fcntl on read pipe: %s", strerror(errno));
+               goto exit;
+       }
+       retval = fcntl(signal_pipe[READ_END], F_SETFL, retval | O_NONBLOCK);
+       if (retval < 0) {
+               err("error fcntl on read pipe: %s", strerror(errno));
+               goto exit;
+       }
+
+       retval = fcntl(signal_pipe[WRITE_END], F_GETFL, 0);
+       if (retval < 0) {
+               err("error fcntl on write pipe: %s", strerror(errno));
+               goto exit;
+       }
+       retval = fcntl(signal_pipe[WRITE_END], F_SETFL, retval | O_NONBLOCK);
+       if (retval < 0) {
+               err("error fcntl on write pipe: %s", strerror(errno));
+               goto exit;
+       }
+
        /* parse the rules and keep them in memory */
        sysfs_init();
        udev_rules_init(&rules, 1);
@@ -1062,35 +1091,6 @@ int main(int argc, char *argv[], char *envp[])
                close(fd);
        }
 
-       /* setup signal handler pipe */
-       retval = pipe(signal_pipe);
-       if (retval < 0) {
-               err("error getting pipes: %s", strerror(errno));
-               goto exit;
-       }
-
-       retval = fcntl(signal_pipe[READ_END], F_GETFL, 0);
-       if (retval < 0) {
-               err("error fcntl on read pipe: %s", strerror(errno));
-               goto exit;
-       }
-       retval = fcntl(signal_pipe[READ_END], F_SETFL, retval | O_NONBLOCK);
-       if (retval < 0) {
-               err("error fcntl on read pipe: %s", strerror(errno));
-               goto exit;
-       }
-
-       retval = fcntl(signal_pipe[WRITE_END], F_GETFL, 0);
-       if (retval < 0) {
-               err("error fcntl on write pipe: %s", strerror(errno));
-               goto exit;
-       }
-       retval = fcntl(signal_pipe[WRITE_END], F_SETFL, retval | O_NONBLOCK);
-       if (retval < 0) {
-               err("error fcntl on write pipe: %s", strerror(errno));
-               goto exit;
-       }
-
        /* set signal handlers */
        memset(&act, 0x00, sizeof(struct sigaction));
        act.sa_handler = (void (*)(int)) sig_handler;