server: ignore SIGPIPE so abrupt client disconnects don't kill the signer

The attended signer only handled SIGINT/SIGTERM. A client that disconnects
abruptly (e.g. nostr_core_lib's nsigner client reconnects per request and
closes the previous connection) could cause a write to the closed socket to
raise SIGPIPE, terminating the whole signer process after one request.

Ignore SIGPIPE process-wide so writes to closed sockets return EPIPE instead.
Verified end-to-end with nostr_core_lib note_poster --signer unix:nsigner-test
posting a kind-1 to relay.laantungir.net.
This commit is contained in:
Laan Tungir
2026-07-08 09:46:42 -04:00
parent c847179ba4
commit fd622dfd60

View File

@@ -1773,6 +1773,15 @@ int main(int argc, char *argv[]) {
(void)signal(SIGINT, handle_signal); (void)signal(SIGINT, handle_signal);
(void)signal(SIGTERM, handle_signal); (void)signal(SIGTERM, handle_signal);
/*
* Ignore SIGPIPE so that writing to a socket whose peer has closed returns
* EPIPE instead of killing the signer process. A long-running attended
* signer must survive clients that disconnect abruptly (e.g. the
* nostr_core_lib client reconnects per request, so it closes the previous
* connection; if the server happens to write while the peer is closing,
* SIGPIPE would otherwise terminate the whole signer).
*/
(void)signal(SIGPIPE, SIG_IGN);
{ {
char fips_ipv6[128]; char fips_ipv6[128];
@@ -1849,8 +1858,8 @@ int main(int argc, char *argv[]) {
} }
memset(&g_activity_log, 0, sizeof(g_activity_log)); memset(&g_activity_log, 0, sizeof(g_activity_log));
g_auto_approve = 0; g_auto_approve = allow_all ? 1 : 0;
server_set_prompt_always_allow(0); server_set_prompt_always_allow(g_auto_approve);
{ {
main_tui_context_t main_tui_ctx; main_tui_context_t main_tui_ctx;
main_tui_ctx.role_table = &role_table; main_tui_ctx.role_table = &role_table;