From 7572bf164180e66db5e8a5c221a406c287117925 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 23 May 2025 02:46:52 +0800 Subject: [PATCH] entry.c: fallback for missing F_DUPFD_CLOEXEC --- src/tup/entry.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git src/tup/entry.c src/tup/entry.c index 16d61fe8..90bc2c96 100644 --- src/tup/entry.c +++ src/tup/entry.c @@ -359,7 +359,19 @@ static int entry_openat_internal(int root_dfd, struct tup_entry *tent) if(!tent) return -1; if(tent->parent == NULL) { - return fcntl(root_dfd, F_DUPFD_CLOEXEC, 0); +#ifdef F_DUPFD_CLOEXEC + int fd = fcntl(root_dfd, F_DUPFD_CLOEXEC, 0); + if(fd != -1 || errno != EINVAL) + return fd; +#endif + int fd = fcntl(root_dfd, F_DUPFD, 0); + if(fd == -1) + return -1; + if(fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { + close(fd); + return -1; + } + return fd; } dfd = entry_openat_internal(root_dfd, tent->parent); -- 2.48.0