From: Bruno Haible Date: Fri, 24 Dec 2021 19:51:37 +0000 (+0100) Subject: passfd: Fix compilation error on IRIX. X-Git-Tag: v1.0~2488 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=86165a8f8faf913059429476adab999e9031640a;p=gnulib.git 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/ChangeLog b/ChangeLog index 5e27c022e9..4cf5222bb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-12-24 Bruno Haible + + passfd: Fix compilation error on IRIX. + * lib/passfd.c (sendfd): On IRIX, ignore CMSG_FIRSTHDR. + (recvfd): Likewise. Produce a fake error ENOTCONN. + 2021-12-24 Bruno Haible tests: Fix link errors on AIX. diff --git a/lib/passfd.c b/lib/passfd.c index 8a3b7bd10b..e22419a3ce 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