aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstddjb/fd_chmod.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/libstddjb/fd_chmod.c
parent45137c6466050c9468931713a7504eae3d08bfce (diff)
downloadskalibs-e99182dab3093f1645f9e4ff216aa752d7443fb1.tar.gz
Save/restore errno in all safe wrappers
Diffstat (limited to 'src/libstddjb/fd_chmod.c')
-rw-r--r--src/libstddjb/fd_chmod.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libstddjb/fd_chmod.c b/src/libstddjb/fd_chmod.c
index be0e0b8..e882711 100644
--- a/src/libstddjb/fd_chmod.c
+++ b/src/libstddjb/fd_chmod.c
@@ -1,16 +1,20 @@
/* ISC license. */
/* OpenBSD manages to bork the fchmod declaration */
+
#include <skalibs/nonposix.h>
+
#include <sys/stat.h>
#include <errno.h>
+
#include <skalibs/djbunix.h>
int fd_chmod (int fd, unsigned int mode)
{
+ int e = errno ;
int r ;
- do
- r = fchmod(fd, (mode_t)mode) ;
- while ((r == -1) && (errno == EINTR)) ;
+ do r = fchmod(fd, (mode_t)mode) ;
+ while (r == -1 && errno == EINTR) ;
+ if (r >= 0) errno = e ;
return r ;
}