chiark / gitweb /
man: add note about parent matching behavior
[elogind.git] / udevd.c
diff --git a/udevd.c b/udevd.c
index 79465a1da08afe289f4d3b1ba3c4487ff06f8bde..23f5fd6980183a2cf56481b3ee903914f6b85512 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -943,6 +943,7 @@ int main(int argc, char *argv[], char *envp[])
                { "debug-trace", 0, NULL, 't' },
                { "verbose", 0, NULL, 'v' },
                { "help", 0, NULL, 'h' },
+               { "version", 0, NULL, 'V' },
                {}
        };
        int rc = 1;
@@ -955,7 +956,7 @@ int main(int argc, char *argv[], char *envp[])
 
        /* parse commandline options */
        while (1) {
-               option = getopt_long(argc, argv, "dtvh", options, NULL);
+               option = getopt_long(argc, argv, "dtvhV", options, NULL);
                if (option == -1)
                        break;
 
@@ -972,7 +973,10 @@ int main(int argc, char *argv[], char *envp[])
                                udev_log_priority = LOG_INFO;
                        break;
                case 'h':
-                       printf("Usage: udevd [--help] [--daemon] [--debug-trace] [--verbose]\n");
+                       printf("Usage: udevd [--help] [--daemon] [--debug-trace] [--verbose] [--version]\n");
+                       goto exit;
+               case 'V':
+                       printf("%s\n", UDEV_VERSION);
                        goto exit;
                default:
                        goto exit;
@@ -1006,6 +1010,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 +1095,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;