On IRIX 6.5, the passfd module does not compile any more, since the headers now define CMSG_FIRSTHDR.
passfd.c: In function `sendfd': passfd.c:57: warning: implicit declaration of function `CMSG_SPACE' passfd.c:74: error: `SCM_RIGHTS' undeclared (first use in this function) passfd.c:74: error: (Each undeclared identifier is reported only once passfd.c:74: error: for each function it appears in.) passfd.c:75: warning: implicit declaration of function `CMSG_LEN' passfd.c: In function `recvfd': passfd.c:141: error: `SCM_RIGHTS' undeclared (first use in this function) But this implementation of passfd, even with fallback definitions of CMSG_SPACE, CMSG_LEN, SCM_RIGHTS would not work. Therefore this patch. 2021-12-24 Bruno Haible <br...@clisp.org> passfd: Fix compilation error on IRIX. * lib/passfd.c (sendfd): On IRIX, ignore CMSG_FIRSTHDR. (recvfd): Likewise. Produce a fake error ENOTCONN. diff --git a/lib/passfd.c b/lib/passfd.c index 8a3b7bd10..e22419a3c 100644 --- a/lib/passfd.c +++ b/lib/passfd.c @@ -52,7 +52,7 @@ sendfd (int sock, int fd) char byte = 0; struct iovec iov; struct msghdr msg; -# ifdef CMSG_FIRSTHDR +# if defined CMSG_FIRSTHDR && !defined __sgi struct cmsghdr *cmsg; char buf[CMSG_SPACE (sizeof fd)]; # endif @@ -66,7 +66,7 @@ sendfd (int sock, int fd) msg.msg_name = NULL; msg.msg_namelen = 0; -# ifdef CMSG_FIRSTHDR +# if defined CMSG_FIRSTHDR && !defined __sgi msg.msg_control = buf; msg.msg_controllen = sizeof buf; cmsg = CMSG_FIRSTHDR (&msg); @@ -112,7 +112,7 @@ recvfd (int sock, int flags) struct msghdr msg; int fd = -1; ssize_t len; -# ifdef CMSG_FIRSTHDR +# if defined CMSG_FIRSTHDR && !defined __sgi struct cmsghdr *cmsg; char buf[CMSG_SPACE (sizeof fd)]; int flags_recvmsg = flags & O_CLOEXEC ? MSG_CMSG_CLOEXEC : 0; @@ -133,7 +133,7 @@ recvfd (int sock, int flags) msg.msg_name = NULL; msg.msg_namelen = 0; -# ifdef CMSG_FIRSTHDR +# if defined CMSG_FIRSTHDR && !defined __sgi msg.msg_control = buf; msg.msg_controllen = sizeof buf; cmsg = CMSG_FIRSTHDR (&msg); @@ -193,6 +193,9 @@ recvfd (int sock, int flags) return -1; } } + + if (fd < 0 && errno == 0) + errno = ENOTCONN; # else errno = ENOSYS; # endif