2021-12-04 21:53:56 +10:30
|
|
|
#include "config.h"
|
2017-08-29 01:35:01 +09:30
|
|
|
#include <common/dev_disconnect.h>
|
2017-09-12 14:26:59 +09:30
|
|
|
#include <common/status.h>
|
2018-01-08 20:31:09 +10:30
|
|
|
#include <common/subdaemon.h>
|
|
|
|
#include <common/version.h>
|
2017-02-24 16:22:56 +10:30
|
|
|
#include <stdio.h>
|
|
|
|
|
2018-03-29 12:36:45 +10:30
|
|
|
static void status_backtrace_print(const char *fmt, ...)
|
2017-09-12 14:26:59 +09:30
|
|
|
{
|
2018-03-29 12:36:45 +10:30
|
|
|
va_list ap;
|
2017-09-12 14:26:59 +09:30
|
|
|
|
2018-03-29 12:36:45 +10:30
|
|
|
va_start(ap, fmt);
|
2019-11-17 22:12:33 +10:30
|
|
|
status_vfmt(LOG_BROKEN, NULL, fmt, ap);
|
2018-03-29 12:36:45 +10:30
|
|
|
va_end(ap);
|
2017-09-12 14:26:59 +09:30
|
|
|
}
|
|
|
|
|
2018-03-29 12:36:45 +10:30
|
|
|
static void status_backtrace_exit(void)
|
2017-09-12 14:26:59 +09:30
|
|
|
{
|
2018-03-29 12:36:45 +10:30
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR, "FATAL SIGNAL");
|
2017-09-12 14:26:59 +09:30
|
|
|
}
|
|
|
|
|
2018-01-15 20:06:17 +10:30
|
|
|
void subdaemon_setup(int argc, char *argv[])
|
|
|
|
{
|
2018-01-08 20:31:09 +10:30
|
|
|
if (argc == 2 && streq(argv[1], "--version")) {
|
|
|
|
printf("%s\n", version());
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2018-01-15 20:06:17 +10:30
|
|
|
for (int i = 1; i < argc; i++) {
|
2018-02-05 14:39:28 +10:30
|
|
|
if (streq(argv[i], "--log-io"))
|
|
|
|
logging_io = true;
|
2017-05-24 19:40:16 +09:30
|
|
|
}
|
|
|
|
|
2019-01-15 14:43:27 +10:30
|
|
|
daemon_maybe_debug(argv);
|
2018-12-08 11:00:56 +10:30
|
|
|
|
2018-02-05 14:39:28 +10:30
|
|
|
#if DEVELOPER
|
2018-01-15 20:06:17 +10:30
|
|
|
for (int i = 1; i < argc; i++) {
|
2018-02-05 14:39:28 +10:30
|
|
|
if (strstarts(argv[i], "--dev-disconnect=")) {
|
|
|
|
dev_disconnect_init(atoi(argv[i]
|
|
|
|
+ strlen("--dev-disconnect=")));
|
|
|
|
}
|
2017-02-24 16:22:56 +10:30
|
|
|
}
|
2017-10-24 12:36:14 +10:30
|
|
|
#endif
|
2018-03-28 13:00:49 +10:30
|
|
|
|
2018-03-29 12:36:45 +10:30
|
|
|
daemon_setup(argv[0], status_backtrace_print, status_backtrace_exit);
|
2018-03-28 13:00:49 +10:30
|
|
|
}
|