lightningd: use env var not cmdline to suppress backtrace.

We now set it up *before* parsing cmdline, so this is more convenient.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-12-17 13:32:30 +10:30
committed by Christian Decker
parent ed9e580358
commit 6b9c525f35
5 changed files with 5 additions and 13 deletions

View File

@@ -34,10 +34,6 @@
char *bitcoin_datadir; char *bitcoin_datadir;
#if DEVELOPER
bool dev_no_backtrace;
#endif
struct backtrace_state *backtrace_state; struct backtrace_state *backtrace_state;
void db_resolve_invoice(struct lightningd *ld, void db_resolve_invoice(struct lightningd *ld,
@@ -245,7 +241,8 @@ int main(int argc, char *argv[])
err_set_progname(argv[0]); err_set_progname(argv[0]);
#if DEVELOPER #if DEVELOPER
if (!dev_no_backtrace) /* Suppresses backtrace (breaks valgrind) */
if (!getenv("LIGHTNINGD_DEV_NO_BACKTRACE"))
#endif #endif
backtrace_state = backtrace_create_state(argv[0], 0, NULL, NULL); backtrace_state = backtrace_create_state(argv[0], 0, NULL, NULL);

View File

@@ -175,7 +175,4 @@ struct chainparams *get_chainparams(const struct lightningd *ld);
/* State for performing backtraces. */ /* State for performing backtraces. */
struct backtrace_state *backtrace_state; struct backtrace_state *backtrace_state;
#if DEVELOPER
extern bool dev_no_backtrace;
#endif
#endif /* LIGHTNING_LIGHTNINGD_LIGHTNINGD_H */ #endif /* LIGHTNING_LIGHTNINGD_LIGHTNINGD_H */

View File

@@ -298,9 +298,6 @@ static void dev_register_opts(struct lightningd *ld)
NULL, ld, "File containing disconnection points"); NULL, ld, "File containing disconnection points");
opt_register_arg("--dev-hsm-seed=<seed>", opt_set_hsm_seed, opt_register_arg("--dev-hsm-seed=<seed>", opt_set_hsm_seed,
NULL, ld, "Hex-encoded seed for HSM"); NULL, ld, "Hex-encoded seed for HSM");
opt_register_noarg("--dev-no-backtrace", opt_set_bool,
&dev_no_backtrace,
"Disable backtrace (crashes under valgrind)");
} }
#endif #endif

View File

@@ -109,7 +109,7 @@ class NodeFactory(object):
if DEVELOPER: if DEVELOPER:
daemon.cmd_line.append("--dev-fail-on-subdaemon-fail") daemon.cmd_line.append("--dev-fail-on-subdaemon-fail")
if VALGRIND: if VALGRIND:
daemon.cmd_line.append("--dev-no-backtrace") daemon.env["LIGHTNINGD_DEV_NO_BACKTRACE"] = "1"
opts = [] if options is None else options opts = [] if options is None else options
for opt in opts: for opt in opts:
daemon.cmd_line.append(opt) daemon.cmd_line.append(opt)

View File

@@ -44,6 +44,7 @@ class TailableProc(object):
self.logs = [] self.logs = []
self.logs_cond = threading.Condition(threading.RLock()) self.logs_cond = threading.Condition(threading.RLock())
self.cmd_line = None self.cmd_line = None
self.env = os.environ
self.running = False self.running = False
self.proc = None self.proc = None
self.outputDir = outputDir self.outputDir = outputDir
@@ -53,7 +54,7 @@ class TailableProc(object):
"""Start the underlying process and start monitoring it. """Start the underlying process and start monitoring it.
""" """
logging.debug("Starting '%s'", " ".join(self.cmd_line)) logging.debug("Starting '%s'", " ".join(self.cmd_line))
self.proc = subprocess.Popen(self.cmd_line, stdout=subprocess.PIPE) self.proc = subprocess.Popen(self.cmd_line, stdout=subprocess.PIPE, env=self.env)
self.thread = threading.Thread(target=self.tail) self.thread = threading.Thread(target=self.tail)
self.thread.daemon = True self.thread.daemon = True
self.thread.start() self.thread.start()