add debug level handover between preinit and main process
authorJohn Crispin <blogic@openwrt.org>
Mon, 18 Nov 2013 10:41:04 +0000 (11:41 +0100)
committerJohn Crispin <blogic@openwrt.org>
Mon, 18 Nov 2013 10:41:04 +0000 (11:41 +0100)
Signed-off-by: John Crispin <blogic@openwrt.org>
initd/preinit.c
procd.c

index eeadbeb3ae8cc36691e216926e101d5a00ccf615..c5f7ada8020f9e94a172482c189df2b788eaddfc 100644 (file)
@@ -34,7 +34,7 @@ static void
 spawn_procd(struct uloop_process *proc, int ret)
 {
        char *wdt_fd = watchdog_fd();
-       char *argv[] = { "/sbin/procd", NULL };
+       char *argv[] = { "/sbin/procd", "-d", "0", NULL };
        struct stat s;
 
        if (plugd_proc.pid > 0)
@@ -49,6 +49,10 @@ spawn_procd(struct uloop_process *proc, int ret)
        DEBUG(2, "Exec to real procd now\n");
        if (wdt_fd)
                setenv("WDTFD", wdt_fd, 1);
+       if (debug)
+               snprintf(argv[2], 2, "%d", debug & 0xf);
+       else
+               argv[1] = NULL;
        execvp(argv[0], argv);
 }
 
diff --git a/procd.c b/procd.c
index a72912a7cec678cd49cbfff313099907dd8ee49b..6fb0a72c687e4f1eee7ba748555502625740ba17 100644 (file)
--- a/procd.c
+++ b/procd.c
@@ -32,7 +32,7 @@ static int usage(const char *prog)
                "Options:\n"
                "\t-s <path>\tPath to ubus socket\n"
                "\t-h <path>\trun as hotplug daemon\n"
-               "\td\t\tEnable debug messages\n"
+               "\t-d <level>\tEnable debug messages\n"
                "\n", prog);
        return 1;
 }
@@ -41,7 +41,7 @@ int main(int argc, char **argv)
 {
        int ch;
 
-       while ((ch = getopt(argc, argv, "ds:h:")) != -1) {
+       while ((ch = getopt(argc, argv, "d:s:h:")) != -1) {
                switch (ch) {
                case 'h':
                        return hotplug_run(optarg);
@@ -49,7 +49,7 @@ int main(int argc, char **argv)
                        ubus_socket = optarg;
                        break;
                case 'd':
-                       debug++;
+                       debug = atoi(optarg);
                        break;
                default:
                        return usage(argv[0]);