summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-31 13:07:26 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-31 13:07:26 +0000
commita16c2745fe843d41bf2046e8362e6963c604e5a8 (patch)
tree66bf1463833e85a606534e13986fbf8af3197575 /ext
parent1a70dfe6f4750a577b889a568527a07ed540d43c (diff)
* 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
Diffstat (limited to 'ext')
-rw-r--r--ext/dbm/dbm.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 6d53960..9b52a4e 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);
}
}