libc: revert inadvertent removal of O_CLOEXEC #ifndefs

Change-Id: I15005181388280363f7aee546bd2ecc0cd5b37e6
This commit is contained in:
Thomas Veerman 2013-07-12 18:38:17 +02:00 committed by Lionel Sambuc
parent 714dd83efe
commit 2a8a99cc6a
3 changed files with 14 additions and 0 deletions

View file

@ -70,8 +70,15 @@ __rec_open(const char *fname, int flags, mode_t mode, const RECNOINFO *openinfo,
dbp = NULL;
/* Open the user's file -- if this fails, we're done. */
if (fname != NULL) {
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
if ((rfd = open(fname, flags | O_CLOEXEC, mode)) == -1)
return NULL;
#if O_CLOEXEC == 0
if (fcntl(rfd, F_SETFD, FD_CLOEXEC) == -1)
goto err;
#endif
}
/* Create a btree in memory (backed by disk). */

View file

@ -213,6 +213,9 @@ fts_open(char * const *argv, int options,
* and ".." are all fairly nasty problems. Note, if we can't get the
* descriptor we run anyway, just more slowly.
*/
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
if (!ISSET(FTS_NOCHDIR)) {
if ((sp->fts_rfd = open(".", O_RDONLY | O_CLOEXEC, 0)) == -1)
SET(FTS_NOCHDIR);

View file

@ -42,6 +42,10 @@ __RCSID("$NetBSD: initdir.c,v 1.3 2012/03/13 21:13:36 christos Exp $");
#include <sys/featuretest.h>
#include <sys/types.h>
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
#endif
#include "reentrant.h"