From a16c2745fe843d41bf2046e8362e6963c604e5a8 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 31 Oct 2011 13:07:26 +0000 Subject: * ext/dbm/dbm.c (fdbm_initialize): use O_CLOEXEC if available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/dbm/dbm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ext/dbm') diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c index 6d5396066d..9b52a4eac2 100644 --- a/ext/dbm/dbm.c +++ b/ext/dbm/dbm.c @@ -137,20 +137,23 @@ fdbm_initialize(int argc, VALUE *argv, VALUE obj) FilePathValue(file); +#ifndef O_CLOEXEC +# define O_CLOEXEC 0 +#endif if (flags & RUBY_DBM_RW_BIT) { flags &= ~RUBY_DBM_RW_BIT; - dbm = dbm_open(RSTRING_PTR(file), flags, mode); + dbm = dbm_open(RSTRING_PTR(file), flags|O_CLOEXEC, mode); } else { dbm = 0; if (mode >= 0) { - dbm = dbm_open(RSTRING_PTR(file), O_RDWR|O_CREAT, mode); + dbm = dbm_open(RSTRING_PTR(file), O_RDWR|O_CREAT|O_CLOEXEC, mode); } if (!dbm) { - dbm = dbm_open(RSTRING_PTR(file), O_RDWR, 0); + dbm = dbm_open(RSTRING_PTR(file), O_RDWR|O_CLOEXEC, 0); } if (!dbm) { - dbm = dbm_open(RSTRING_PTR(file), O_RDONLY, 0); + dbm = dbm_open(RSTRING_PTR(file), O_RDONLY|O_CLOEXEC, 0); } } -- cgit v1.2.3