initd: allow overriding early PATH through build time define
[project/procd.git] / procd.c
diff --git a/procd.c b/procd.c
index 6fb0a72..e41d98a 100644 (file)
--- a/procd.c
+++ b/procd.c
@@ -15,6 +15,7 @@
 #include <sys/wait.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/reboot.h>
 
 #include <unistd.h>
 #include <getopt.h>
@@ -40,6 +41,14 @@ static int usage(const char *prog)
 int main(int argc, char **argv)
 {
        int ch;
+       char *dbglvl = getenv("DBGLVL");
+
+       ulog_open(ULOG_KMSG, LOG_DAEMON, "procd");
+
+       if (dbglvl) {
+               debug = atoi(dbglvl);
+               unsetenv("DBGLVL");
+       }
 
        while ((ch = getopt(argc, argv, "d:s:h:")) != -1) {
                switch (ch) {
@@ -55,6 +64,7 @@ int main(int argc, char **argv)
                        return usage(argv[0]);
                }
        }
+       setsid();
        uloop_init();
        procd_signal();
        trigger_init();
@@ -63,6 +73,7 @@ int main(int argc, char **argv)
        else
                procd_state_next();
        uloop_run();
+       uloop_done();
 
        return 0;
 }