aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2023-04-13 19:32:13 +0200
committerStefano Brivio <sbrivio@redhat.com>2023-04-13 19:32:13 +0200
commit940bd3eff922c46ac280136e3674ee70ea40f08e (patch)
tree08194240dfa2dd320fce23d21e4de13becab41a0
parent1a3ade90371f7e9490e8f3be0aff83f2e178c327 (diff)
downloadpasst-940bd3eff922c46ac280136e3674ee70ea40f08e.tar
passt-940bd3eff922c46ac280136e3674ee70ea40f08e.tar.gz
passt-940bd3eff922c46ac280136e3674ee70ea40f08e.tar.bz2
passt-940bd3eff922c46ac280136e3674ee70ea40f08e.tar.lz
passt-940bd3eff922c46ac280136e3674ee70ea40f08e.tar.xz
passt-940bd3eff922c46ac280136e3674ee70ea40f08e.tar.zst
passt-940bd3eff922c46ac280136e3674ee70ea40f08e.zip
passt: Fix error check for signal(), improve error messages
Valtteri reports that if SIGPIPE already has a disposition set by the parent process, such as systemd with the default setting of IgnoreSIGPIPE=yes, signal() will return the previous value, not zero, and this is not an error: check for SIG_ERR instead. While at it, split messages for failures of sigaction() and signal(), and report the actual error. Reported-by: Valtteri Vuorikoski <vuori@notcom.org> Fixes: 8534be076c73 ("Catch failures when installing signal handlers") Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--passt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/passt.c b/passt.c
index 7fa1170..3b9b36b 100644
--- a/passt.c
+++ b/passt.c
@@ -204,8 +204,15 @@ int main(int argc, char **argv)
name = basename(argv0);
if (strstr(name, "pasta")) {
sa.sa_handler = pasta_child_handler;
- if (sigaction(SIGCHLD, &sa, NULL) || signal(SIGPIPE, SIG_IGN))
- die("Couldn't install signal handlers");
+ if (sigaction(SIGCHLD, &sa, NULL)) {
+ die("Couldn't install signal handlers: %s",
+ strerror(errno));
+ }
+
+ if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
+ die("Couldn't set disposition for SIGPIPE: %s",
+ strerror(errno));
+ }
c.mode = MODE_PASTA;
log_name = "pasta";