[pacman-dev] [PATCH] NO_MSGSIGNAL and SIGPOLL don't exist on darwin

Cameron Katri katri.cameron at gmail.com
Tue Sep 1 19:50:39 UTC 2020


I believe I found a more portable solution. We use signal(SIGPIPE, SIG_IGN); which will block SIGPIPE, and if MSG_NOSIGNAL is not supported we set it to 0x0 so that it just gets ignored. Hopefully this is a more comprehensive solution.  

>From ea38d52b8301eacaf0b7cd76ba5e1c2bf601f4f5 Mon Sep 17 00:00:00 2001
From: Cameron Katri <katri.cameron at gmail.com>
Date: Mon, 31 Aug 2020 09:50:09 -0400
Subject: [PATCH] Fix compilation on Darwin

---
 lib/libalpm/util.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index b70a8192..4a51b63f 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -34,6 +34,11 @@
 #include <fnmatch.h>
 #include <poll.h>
 
+/* no MSG_NOSIGNAL support */
+#ifndef MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0x0
+#endif
+
 /* libarchive */
 #include <archive.h>
 #include <archive_entry.h>
@@ -474,6 +479,8 @@ static int _alpm_chroot_write_to_child(alpm_handle_t *handle, int fd,
 		}
 	}
 
+	signal(SIGPIPE, SIG_IGN);
+
 	nwrite = send(fd, buf, *buf_size, MSG_NOSIGNAL);
 
 	if(nwrite != -1) {
@@ -557,8 +564,11 @@ static void _alpm_reset_signals(void)
 	int *i, signals[] = {
 		SIGABRT, SIGALRM, SIGBUS, SIGCHLD, SIGCONT, SIGFPE, SIGHUP, SIGILL,
 		SIGINT, SIGKILL, SIGPIPE, SIGQUIT, SIGSEGV, SIGSTOP, SIGTERM, SIGTSTP,
-		SIGTTIN, SIGTTOU, SIGUSR1, SIGUSR2, SIGPOLL, SIGPROF, SIGSYS, SIGTRAP,
+		SIGTTIN, SIGTTOU, SIGUSR1, SIGUSR2, SIGPROF, SIGSYS, SIGTRAP,
 		SIGURG, SIGVTALRM, SIGXCPU, SIGXFSZ,
+#ifndef __APPLE__
+		SIGPOLL,
+#endif
 		0
 	};
 	struct sigaction def;
-- 
2.28.0


More information about the pacman-dev mailing list