| 123 | #endif |
| 124 | |
| 125 | void daemon_setup(const char *argv0, |
| 126 | void (*backtrace_print)(const char *fmt, ...), |
| 127 | void (*backtrace_exit)(void)) |
| 128 | { |
| 129 | common_setup(argv0); |
| 130 | #if BACKTRACE_SUPPORTED |
| 131 | bt_print = backtrace_print; |
| 132 | bt_exit = backtrace_exit; |
| 133 | #if DEVELOPER |
| 134 | /* Suppresses backtrace (breaks valgrind) */ |
| 135 | if (!getenv("LIGHTNINGD_DEV_NO_BACKTRACE")) |
| 136 | backtrace_state = backtrace_create_state(argv0, 0, NULL, NULL); |
| 137 | add_steal_notifiers(NULL); |
| 138 | #else |
| 139 | backtrace_state = backtrace_create_state(argv0, 0, NULL, NULL); |
| 140 | #endif |
| 141 | crashlog_activate(); |
| 142 | #endif |
| 143 | |
| 144 | #if DEVELOPER |
| 145 | /* This has significant overhead, so we only enable it if told */ |
| 146 | if (getenv("LIGHTNINGD_DEV_MEMLEAK")) |
| 147 | memleak_init(); |
| 148 | #endif |
| 149 | |
| 150 | /* We handle write returning errors! */ |
| 151 | signal(SIGPIPE, SIG_IGN); |
| 152 | |
| 153 | io_poll_override(daemon_poll); |
| 154 | } |
| 155 | |
| 156 | void daemon_shutdown(void) |
| 157 | { |
no test coverage detected