From 2a8a99cc6a4b274f6c3dae2bddb0848e65cbfe19 Mon Sep 17 00:00:00 2001 From: Thomas Veerman Date: Fri, 12 Jul 2013 18:38:17 +0200 Subject: [PATCH] libc: revert inadvertent removal of O_CLOEXEC #ifndefs Change-Id: I15005181388280363f7aee546bd2ecc0cd5b37e6 --- lib/libc/db/recno/rec_open.c | 7 +++++++ lib/libc/gen/fts.c | 3 +++ lib/libc/gen/initdir.c | 4 ++++ 3 files changed, 14 insertions(+) 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" -- 2.44.0