X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=initd%2Fpreinit.c;h=f38d8ef2a014acac7311a06a16c7a2401907debb;hb=370b68a9c3514ecb2fb6b814ba58e4e41f4f26c0;hp=eeadbeb3ae8cc36691e216926e101d5a00ccf615;hpb=916f95cb58604038695347ee41a430d8ca1f0556;p=project%2Fprocd.git diff --git a/initd/preinit.c b/initd/preinit.c index eeadbeb..f38d8ef 100644 --- a/initd/preinit.c +++ b/initd/preinit.c @@ -31,11 +31,29 @@ static struct uloop_process preinit_proc; static struct uloop_process plugd_proc; static void +check_dbglvl(void) +{ + FILE *fp = fopen("/tmp/debug_level", "r"); + int lvl = 0; + + if (!fp) + return; + if (fscanf(fp, "%d", &lvl) == EOF) + ERROR("failed to read debug level\n"); + fclose(fp); + unlink("/tmp/debug_level"); + + if (lvl > 0 && lvl < 5) + debug = lvl; +} + +static void spawn_procd(struct uloop_process *proc, int ret) { char *wdt_fd = watchdog_fd(); - char *argv[] = { "/sbin/procd", NULL }; + char *argv[] = { "/sbin/procd", NULL}; struct stat s; + char dbg[2]; if (plugd_proc.pid > 0) kill(plugd_proc.pid, SIGKILL); @@ -49,6 +67,12 @@ spawn_procd(struct uloop_process *proc, int ret) DEBUG(2, "Exec to real procd now\n"); if (wdt_fd) setenv("WDTFD", wdt_fd, 1); + check_dbglvl(); + if (debug > 0) { + snprintf(dbg, 2, "%d", debug); + setenv("DBGLVL", dbg, 1); + } + execvp(argv[0], argv); }