From: Thomas Veerman Date: Fri, 12 Jul 2013 16:38:17 +0000 (+0200) Subject: libc: revert inadvertent removal of O_CLOEXEC #ifndefs X-Git-Tag: v3.3.0~893 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=2a8a99cc6a4b274f6c3dae2bddb0848e65cbfe19;p=minix.git libc: revert inadvertent removal of O_CLOEXEC #ifndefs Change-Id: I15005181388280363f7aee546bd2ecc0cd5b37e6 --- diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c index cc1863fa1..fa5237572 100644 --- a/lib/libc/db/recno/rec_open.c +++ b/lib/libc/db/recno/rec_open.c @@ -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). */ diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index b83b0ab72..16af0d43b 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -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); diff --git a/lib/libc/gen/initdir.c b/lib/libc/gen/initdir.c index 8c1785153..2ab6591a9 100644 --- a/lib/libc/gen/initdir.c +++ b/lib/libc/gen/initdir.c @@ -42,6 +42,10 @@ __RCSID("$NetBSD: initdir.c,v 1.3 2012/03/13 21:13:36 christos Exp $"); #include #include +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + #endif #include "reentrant.h"