mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
4ffda340d3
And turn "" includes into full-path (which makes it easier to put config.h first, and finds some cases check-includes.sh missed previously). config.h sets _GNU_SOURCE which really needs to be done before any '#includes': we mainly got away with it with glibc, but other platforms like Alpine may have stricter requirements. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
47 lines
938 B
C
47 lines
938 B
C
#include "config.h"
|
|
#include <common/dev_disconnect.h>
|
|
#include <common/status.h>
|
|
#include <common/subdaemon.h>
|
|
#include <common/version.h>
|
|
#include <stdio.h>
|
|
|
|
static void status_backtrace_print(const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
status_vfmt(LOG_BROKEN, NULL, fmt, ap);
|
|
va_end(ap);
|
|
}
|
|
|
|
static void status_backtrace_exit(void)
|
|
{
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR, "FATAL SIGNAL");
|
|
}
|
|
|
|
void subdaemon_setup(int argc, char *argv[])
|
|
{
|
|
if (argc == 2 && streq(argv[1], "--version")) {
|
|
printf("%s\n", version());
|
|
exit(0);
|
|
}
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
if (streq(argv[i], "--log-io"))
|
|
logging_io = true;
|
|
}
|
|
|
|
daemon_maybe_debug(argv);
|
|
|
|
#if DEVELOPER
|
|
for (int i = 1; i < argc; i++) {
|
|
if (strstarts(argv[i], "--dev-disconnect=")) {
|
|
dev_disconnect_init(atoi(argv[i]
|
|
+ strlen("--dev-disconnect=")));
|
|
}
|
|
}
|
|
#endif
|
|
|
|
daemon_setup(argv[0], status_backtrace_print, status_backtrace_exit);
|
|
}
|