core: replace "dup()" by "fcntl(fd, F_DUPFD_CLOEXEC, 0)"

(cherry picked from commit 1e572ebf87)
This commit is contained in:
Thomas Haller 2017-11-27 13:39:18 +01:00
parent a792a7f9c3
commit f000c76be4
2 changed files with 2 additions and 2 deletions

View file

@ -2835,7 +2835,7 @@ nm_utils_fd_get_contents (int fd,
if (fd_keeper >= 0)
fd2 = nm_steal_fd (&fd_keeper);
else {
fd2 = dup (fd);
fd2 = fcntl (fd, F_DUPFD_CLOEXEC, 0);
if (fd2 < 0)
return _get_contents_error (error, 0, "error during dup");
}

View file

@ -1318,7 +1318,7 @@ svWriteFile (shvarFile *s, int mode, GError **error)
return FALSE;
}
tmpfd = dup (s->fd);
tmpfd = fcntl (s->fd, F_DUPFD_CLOEXEC, 0);
if (tmpfd == -1) {
int errsv = errno;