Skip to content

Commit

Permalink
lightningd/log.c: Fix up handling of SIGHUP.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZmnSCPxj committed Dec 2, 2020
1 parent a3e0120 commit d270222
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 17 additions & 1 deletion lightningd/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,23 @@ static void setup_log_rotation(struct lightningd *ld)
io_fd_block(signalfds[1], false);
memset(&act, 0, sizeof(act));
act.sa_handler = handle_sighup;
act.sa_flags = SA_RESETHAND;
/* We do not need any particular flags; the sigaction
* default behavior (EINTR any system calls, pass only
* the signo to the handler, retain the same signal
* handler throughout) is fine with us.
*/
act.sa_flags = 0;
/* Block all signals while handling SIGHUP.
* Without this, e.g. an inopportune SIGCHLD while we
* are doing a `write` to the SIGHUP signal pipe could
* prevent us from sending the byte and performing the
* log rotation in the main loop.
*
* The SIGHUP handler does very little anyway, and
* the blocked signals will get delivered soon after
* the SIGHUP handler returns.
*/
sigfillset(&act.sa_mask);

if (sigaction(SIGHUP, &act, NULL) != 0)
err(1, "Setting up SIGHUP handler");
Expand Down
1 change: 0 additions & 1 deletion tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,6 @@ def test_feerates(node_factory):
assert htlc_success_cost == htlc_feerate * 703 // 1000


@pytest.mark.xfail(strict=True)
def test_logging(node_factory):
# Since we redirect, node.start() will fail: do manually.
l1 = node_factory.get_node(options={'log-file': 'logfile'}, start=False)
Expand Down

0 comments on commit d270222

Please sign in to comment.