summaryrefslogtreecommitdiffstats
path: root/lib/sysfs.c
diff options
context:
space:
mode:
authorCristian Rodríguez2015-04-10 20:57:58 +0200
committerKarel Zak2015-04-14 11:38:02 +0200
commitd1f9c0969eb24d0a5ec5d862bd41b1bd5f3103f0 (patch)
treeb29132d2450d36276c15d28a20d700e041e6db76 /lib/sysfs.c
parenttests: make libmount python context tests sensitive to USE_LIBMOUNT_FORCE_MOU... (diff)
downloadkernel-qcow2-util-linux-d1f9c0969eb24d0a5ec5d862bd41b1bd5f3103f0.tar.gz
kernel-qcow2-util-linux-d1f9c0969eb24d0a5ec5d862bd41b1bd5f3103f0.tar.xz
kernel-qcow2-util-linux-d1f9c0969eb24d0a5ec5d862bd41b1bd5f3103f0.zip
lib/sysfs.c: use fcntl(..F_DUPFD_CLOEXEC) instead of dup(2)
"The two descriptors do not share file descriptor flags (the close-on-exec flag). The close-on-exec flag for the duplicate descriptor is off"
Diffstat (limited to 'lib/sysfs.c')
-rw-r--r--lib/sysfs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sysfs.c b/lib/sysfs.c
index ac3559619..1b2019112 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -246,7 +246,7 @@ DIR *sysfs_opendir(struct sysfs_cxt *cxt, const char *attr)
* -- we cannot use cxt->sysfs_fd directly, because closedir()
* will close this our persistent file descriptor.
*/
- fd = dup(cxt->dir_fd);
+ fd = fcntl(cxt->dir_fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
if (fd < 0)
return NULL;