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