The fcntl call to set FD_CLOEXEC can be performed directly with the
previously performed open call by using the O_CLOEXEC flag.
O_CLOEXEC is required by POSIX.1-2008.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
fd = open (db->filename,
(db->readonly ? O_RDONLY : O_RDWR)
- | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
+ | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW | O_CLOEXEC);
saved_errno = errno;
db->fp = NULL;
if (fd >= 0) {
return 0;
}
- /* Do not inherit fd in spawned processes (e.g. nscd) */
- fcntl (fileno (db->fp), F_SETFD, FD_CLOEXEC);
-
buflen = BUFLEN;
buf = MALLOCARRAY (buflen, char);
if (NULL == buf) {