aboutsummaryrefslogtreecommitdiffstats
path: root/src/libunixonacid/ancil_send_fd.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-01-01 13:47:45 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-01-01 13:47:45 +0000
commite99182dab3093f1645f9e4ff216aa752d7443fb1 (patch)
tree175a373c32a58783edd41901d4baf6e68626c7ec /src/libunixonacid/ancil_send_fd.c
parent45137c6466050c9468931713a7504eae3d08bfce (diff)
downloadskalibs-e99182dab3093f1645f9e4ff216aa752d7443fb1.tar.gz
Save/restore errno in all safe wrappers
Diffstat (limited to 'src/libunixonacid/ancil_send_fd.c')
-rw-r--r--src/libunixonacid/ancil_send_fd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libunixonacid/ancil_send_fd.c b/src/libunixonacid/ancil_send_fd.c
index 5573d5c..7258eb1 100644
--- a/src/libunixonacid/ancil_send_fd.c
+++ b/src/libunixonacid/ancil_send_fd.c
@@ -31,13 +31,15 @@ int ancil_send_fd (int sock, int fd, char ch)
.msg_controllen = CMSG_SPACE(sizeof(int))
} ;
struct cmsghdr *c = CMSG_FIRSTHDR(&hdr) ;
+ int e = errno ;
memset(hdr.msg_control, 0, hdr.msg_controllen) ;
c->cmsg_level = SOL_SOCKET ;
c->cmsg_type = SCM_RIGHTS ;
c->cmsg_len = CMSG_LEN(sizeof(int)) ;
memcpy(CMSG_DATA(c), &fd, sizeof(int)) ;
do r = sendmsg(sock, &hdr, MSG_NOSIGNAL) ;
- while (r < 0 && errno == EINTR) ;
+ while (r == -1 && errno == EINTR) ;
if (r <= 0) return 0 ;
+ errno = e ;
return 1 ;
}