summaryrefslogtreecommitdiff
path: root/ext/dbm
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dbm')
-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);
}
}