mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 09:04:22 +01:00
lightningd/log.c: Fix up handling of SIGHUP.
Fixes: #4240 ChangeLog-Fixed: log: Do not terminate on the second received SIGHUP.
This commit is contained in:
committed by
Rusty Russell
parent
67d8fdcc75
commit
a437936c78
@@ -642,7 +642,23 @@ static void setup_log_rotation(struct lightningd *ld)
|
|||||||
io_fd_block(signalfds[1], false);
|
io_fd_block(signalfds[1], false);
|
||||||
memset(&act, 0, sizeof(act));
|
memset(&act, 0, sizeof(act));
|
||||||
act.sa_handler = handle_sighup;
|
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)
|
if (sigaction(SIGHUP, &act, NULL) != 0)
|
||||||
err(1, "Setting up SIGHUP handler");
|
err(1, "Setting up SIGHUP handler");
|
||||||
|
|||||||
@@ -1532,7 +1532,6 @@ def test_feerates(node_factory):
|
|||||||
assert htlc_success_cost == htlc_feerate * 703 // 1000
|
assert htlc_success_cost == htlc_feerate * 703 // 1000
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(strict=True)
|
|
||||||
def test_logging(node_factory):
|
def test_logging(node_factory):
|
||||||
# Since we redirect, node.start() will fail: do manually.
|
# Since we redirect, node.start() will fail: do manually.
|
||||||
l1 = node_factory.get_node(options={'log-file': 'logfile'}, start=False)
|
l1 = node_factory.get_node(options={'log-file': 'logfile'}, start=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user