mdev: add commented-out debug code to open stdio.
authorDenis Vlasenko <vda.linux@googlemail.com>
Sat, 31 May 2008 18:27:58 +0000 (18:27 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Sat, 31 May 2008 18:27:58 +0000 (18:27 -0000)
util-linux/mdev.c

index a32c04f6bfcbf1fc2506270de7f6b55a21409587..057b9e4ff87f4ffd020c5a1e2033e7a22e4f9ff3 100644 (file)
@@ -392,6 +392,15 @@ int mdev_main(int argc, char **argv)
        char *env_path;
        RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE);
 
+#ifdef YOU_WANT_TO_DEBUG_HOTPLUG_EVENTS
+       /* Kernel cannot provide suitable stdio fds for us, do it ourself */
+       /* Replace LOGFILE by other file or device name if you need */
+#define LOGFILE "/dev/console"
+       xmove_fd(xopen("/dev/null", O_RDONLY), STDIN_FILENO);
+       xmove_fd(xopen(LOGFILE, O_WRONLY|O_APPEND), STDOUT_FILENO);
+       xmove_fd(xopen(LOGFILE, O_WRONLY|O_APPEND), STDERR_FILENO);
+#endif
+
        xchdir("/dev");
 
        if (argc == 2 && !strcmp(argv[1], "-s")) {