Skip to content

Commit

Permalink
lightningd: use env var not cmdline to suppress backtrace.
Browse files Browse the repository at this point in the history
We now set it up *before* parsing cmdline, so this is more convenient.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Dec 20, 2017
1 parent ed9e580 commit 6b9c525
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 13 deletions.
7 changes: 2 additions & 5 deletions lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@

char *bitcoin_datadir;

#if DEVELOPER
bool dev_no_backtrace;
#endif

struct backtrace_state *backtrace_state;

void db_resolve_invoice(struct lightningd *ld,
Expand Down Expand Up @@ -245,7 +241,8 @@ int main(int argc, char *argv[])
err_set_progname(argv[0]);

#if DEVELOPER
if (!dev_no_backtrace)
/* Suppresses backtrace (breaks valgrind) */
if (!getenv("LIGHTNINGD_DEV_NO_BACKTRACE"))
#endif
backtrace_state = backtrace_create_state(argv[0], 0, NULL, NULL);

Expand Down
3 changes: 0 additions & 3 deletions lightningd/lightningd.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,4 @@ struct chainparams *get_chainparams(const struct lightningd *ld);
/* State for performing backtraces. */
struct backtrace_state *backtrace_state;

#if DEVELOPER
extern bool dev_no_backtrace;
#endif
#endif /* LIGHTNING_LIGHTNINGD_LIGHTNINGD_H */
3 changes: 0 additions & 3 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ static void dev_register_opts(struct lightningd *ld)
NULL, ld, "File containing disconnection points");
opt_register_arg("--dev-hsm-seed=<seed>", opt_set_hsm_seed,
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

Expand Down
2 changes: 1 addition & 1 deletion tests/test_lightningd.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_node(self, disconnect=None, options=None, may_fail=False, random_hsm=Fal
if DEVELOPER:
daemon.cmd_line.append("--dev-fail-on-subdaemon-fail")
if VALGRIND:
daemon.cmd_line.append("--dev-no-backtrace")
daemon.env["LIGHTNINGD_DEV_NO_BACKTRACE"] = "1"
opts = [] if options is None else options
for opt in opts:
daemon.cmd_line.append(opt)
Expand Down
3 changes: 2 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self, outputDir=None):
self.logs = []
self.logs_cond = threading.Condition(threading.RLock())
self.cmd_line = None
self.env = os.environ
self.running = False
self.proc = None
self.outputDir = outputDir
Expand All @@ -53,7 +54,7 @@ def start(self):
"""Start the underlying process and start monitoring it.
"""
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.daemon = True
self.thread.start()
Expand Down

0 comments on commit 6b9c525

Please sign in to comment.