From: Cristian Rodríguez Date: Fri, 10 Apr 2015 18:57:58 +0000 (-0300) Subject: lib/sysfs.c: use fcntl(..F_DUPFD_CLOEXEC) instead of dup(2) X-Git-Tag: v2.27-rc1~269 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1f9c0969eb24d0a5ec5d862bd41b1bd5f3103f0;p=thirdparty%2Futil-linux.git 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" --- diff --git a/lib/sysfs.c b/lib/sysfs.c index ac35596190..1b2019112d 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;