chiark / gitweb /
[PATCH] udevd: support -d switch to become a daemon
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Sun, 16 Jan 2005 03:06:22 +0000 (04:06 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:21:58 +0000 (23:21 -0700)
udevd.c

diff --git a/udevd.c b/udevd.c
index 0049e69..f1e28d9 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -472,6 +472,24 @@ int main(int argc, char *argv[], char *envp[])
                goto exit;
        }
 
+       /* daemonize on request */
+       if (argc == 2 && strcmp(argv[1], "-d") == 0) {
+               pid_t pid;
+
+               pid = fork();
+               switch (pid) {
+               case 0:
+                       dbg("damonized fork running");
+                       break;
+               case -1:
+                       dbg("fork of daemon failed");
+                       goto exit;
+               default:
+                       logging_close();
+                       exit(0);
+               }
+       }
+
        /* make sure we don't lock any path */
        chdir("/");
        umask(umask(077) | 022);