From aff2ad8d3c43ec638765f4e3630a6faf23b0180a Mon Sep 17 00:00:00 2001 From: ThePedroo Date: Sun, 22 Jun 2025 02:10:43 -0300 Subject: [PATCH] add: `SIGPIPE` handling in ReZygiskd This commit adds "SIGPIPE" signal handling in ReZygiskd. Some processes might die while ReZygiskd is still processing the response, and it will fail to write to the reader, now dead, resulting in a "SIGPIPE". Without proper handling, the process (ReZygiskd) would die, and this commit properly handled it to gracefully log it instead of dying. --- zygiskd/src/companion.c | 6 +----- zygiskd/src/zygiskd.c | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/zygiskd/src/companion.c b/zygiskd/src/companion.c index 4e9ca96..3177f0a 100644 --- a/zygiskd/src/companion.c +++ b/zygiskd/src/companion.c @@ -121,11 +121,7 @@ void companion_entry(int fd) { ASSURE_SIZE_WRITE("ZygiskdCompanion", "module_entry", ret, sizeof(uint8_t)); } - struct sigaction sa; - memset(&sa, 0, sizeof(sa)); - - sigemptyset(&sa.sa_mask); - sa.sa_handler = SIG_IGN; + struct sigaction sa = { .sa_handler = SIG_IGN }; sigaction(SIGPIPE, &sa, NULL); while (1) { diff --git a/zygiskd/src/zygiskd.c b/zygiskd/src/zygiskd.c index eb1d2d1..fe00454 100644 --- a/zygiskd/src/zygiskd.c +++ b/zygiskd/src/zygiskd.c @@ -357,6 +357,9 @@ void zygiskd_start(char *restrict argv[]) { return; } + struct sigaction sa = { .sa_handler = SIG_IGN }; + sigaction(SIGPIPE, &sa, NULL); + bool first_process = true; while (1) { int client_fd = accept(socket_fd, NULL, NULL);