1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2011-10-31 13:07:26 +00:00
parent 1a70dfe6f4
commit a16c2745fe
2 changed files with 11 additions and 4 deletions

View file

@ -1,3 +1,7 @@
Mon Oct 31 22:04:54 2011 Tanaka Akira <akr@fsij.org>
* ext/dbm/dbm.c (fdbm_initialize): use O_CLOEXEC if available.
Mon Oct 31 21:47:48 2011 Tanaka Akira <akr@fsij.org>
* include/ruby/intern.h (rb_fd_fix_cloexec): renamed from

View file

@ -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);
}
}