@@ -35,6 +35,7 @@ static int usage(const char *prog)
" -h <path> run as hotplug daemon\n"
" -d <level> Enable debug messages\n"
" -S Print messages to stdout\n"
+ " -D Run procd as daemon process\n"
"\n", prog);
return 1;
}
@@ -50,7 +51,7 @@ int main(int argc, char **argv)
unsetenv("DBGLVL");
}
- while ((ch = getopt(argc, argv, "d:s:h:S")) != -1) {
+ while ((ch = getopt(argc, argv, "d:s:h:SD")) != -1) {
switch (ch) {
case 'h':
return hotplug_run(optarg);
@@ -63,6 +64,9 @@ int main(int argc, char **argv)
case 'S':
ulog_channels = ULOG_STDIO;
break;
+ case 'D':
+ daemon(1, 1);
+ break;
default:
return usage(argv[0]);
}
@@ -74,10 +78,7 @@ int main(int argc, char **argv)
setsid();
uloop_init();
procd_signal();
- if (getpid() != 1)
- procd_connect_ubus();
- else
- procd_state_next();
+ procd_state_next();
uloop_run();
uloop_done();
Add arg -D to start procd in daemon mode. This allows running procd directly, not only via /init. Useful for CI environments to start services like ubus and netifd without needing the whole init process. To make this work procd also spawns services when running on a different pid than 1, normal when started via terminal. Before it would only try to connect to an existing ubus instance. The -D arg handling was kindly created (with < 60 seconds RTT) by John, I just created the patch and removed pid checking. CC: John Crispin <john@phrozen.org> Signed-off-by: Paul Spooren <mail@aparcar.org> --- v2: added usage/help message procd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)