lightningd: activate crashlog before forking off as daemon.

This avoids cases like #2348 where the user gets *no* clue as to what
went wrong.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-02-18 12:00:00 +10:30 committed by Christian Decker
parent a405c22fc9
commit 8c22b91a70

View File

@ -764,6 +764,11 @@ int main(int argc, char *argv[])
* can start talking to us. */ * can start talking to us. */
plugins_config(ld->plugins); plugins_config(ld->plugins);
/*~ Setting this (global) activates the crash log: we don't usually need
* a backtrace if we fail during startup. We do this before daemonize,
* in case that runs into trouble. */
crashlog = ld->log;
/*~ We defer --daemon until we've completed most initialization: that /*~ We defer --daemon until we've completed most initialization: that
* way we'll exit with an error rather than silently exiting 0, then * way we'll exit with an error rather than silently exiting 0, then
* realizing we can't start and forcing the confused user to read the * realizing we can't start and forcing the confused user to read the
@ -808,10 +813,6 @@ int main(int argc, char *argv[])
* can start the poll loop which queries bitcoind for new blocks. */ * can start the poll loop which queries bitcoind for new blocks. */
begin_topology(ld->topology); begin_topology(ld->topology);
/*~ Setting this (global) activates the crash log: we don't usually need
* a backtrace if we fail during startup. */
crashlog = ld->log;
/*~ The root of every backtrace (almost). This is our main event /*~ The root of every backtrace (almost). This is our main event
* loop. */ * loop. */
for (;;) { for (;;) {