aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCismonX <admin@cismon.net>2025-08-12 08:55:42 +0800
committerBernd Schubert <bernd@bsbernd.com>2025-08-19 20:07:15 +0200
commitaf48907c0b534f7f81f639f546bfcea6bc8e99b1 (patch)
treeb4fcd7304d657cca01011fb3c3acbcbf6fc929a4
parent6d9ff1c57c1c3107c3e012373f28b871cd6ef2c9 (diff)
downloadlibfuse-af48907c0b534f7f81f639f546bfcea6bc8e99b1.tar.gz
fuse_loop_mt.c: fix close-on-exec flag on clone fd
Closes: https://github.com/libfuse/libfuse/issues/1310 Signed-off-by: CismonX <admin@cismon.net> (cherry picked from commit 42b9b3bbb71d38be6a5670bbd0948cf406c1573c)
-rw-r--r--lib/fuse_loop_mt.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c
index d6be998..01c51cc 100644
--- a/lib/fuse_loop_mt.c
+++ b/lib/fuse_loop_mt.c
@@ -275,9 +275,15 @@ static int fuse_clone_chan_fd_default(struct fuse_session *se)
strerror(errno));
return -1;
}
-#ifndef O_CLOEXEC
- fcntl(clonefd, F_SETFD, FD_CLOEXEC);
-#endif
+ if (!O_CLOEXEC) {
+ res = fcntl(clonefd, F_SETFD, FD_CLOEXEC);
+ if (res == -1) {
+ fuse_log(FUSE_LOG_ERR, "fuse: failed to set CLOEXEC: %s\n",
+ strerror(errno));
+ close(clonefd);
+ return -1;
+ }
+ }
masterfd = se->fd;
res = ioctl(clonefd, FUSE_DEV_IOC_CLONE, &masterfd);