diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-07 11:17:17 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-07 11:17:17 +0000 |
commit | e4e5b7df4cca2cedba1ec2b52f75c450a0c618ce (patch) | |
tree | 98e4840ab87cb252aa98f3ae429568fa2441606e /ext/dbm/dbm.c | |
parent | 66595f389473a4040e318fdfcc4b5d81cf8c2698 (diff) | |
download | ruby-e4e5b7df4cca2cedba1ec2b52f75c450a0c618ce.tar.gz |
* ext/dbm/extconf.rb: check dbm_pagfno() and dbm_dirfno().
* ext/dbm/dbm.c: use above to set close-on-exec flag.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dbm/dbm.c')
-rw-r--r-- | ext/dbm/dbm.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c index 2bfd62b3c9..93c1f80c96 100644 --- a/ext/dbm/dbm.c +++ b/ext/dbm/dbm.c @@ -162,6 +162,30 @@ fdbm_initialize(int argc, VALUE *argv, VALUE obj) } } + if (dbm) { + /* + * History of dbm_pagfno() and dbm_dirfno() in ndbm and its compatibles. + * + * 1986: 4.3BSD provides ndbm. + * It provides dbm_pagfno() and dbm_dirfno() as macros. + * 1991: gdbm-1.5 provides them as functions. + * They returns a same descriptor. + * (Earlier releases may have the functions too.) + * 1991: Net/2 provides Berkeley DB. + * It doesn't provide dbm_pagfno() and dbm_dirfno(). + * 1992: 4.4BSD Alpha provides Berkeley DB with dbm_dirfno() as a function. + * dbm_pagfno() is a macro as DBM_PAGFNO_NOT_AVAILABLE. + * 2011: gdbm-1.9 creates a separate dir file. + * dbm_pagfno() and dbm_dirfno() returns different descriptors. + */ +#if defined(HAVE_DBM_PAGFNO) + rb_fd_fix_cloexec(dbm_pagfno(dbm)); +#endif +#if defined(HAVE_DBM_DIRFNO) + rb_fd_fix_cloexec(dbm_dirfno(dbm)); +#endif + } + if (!dbm) { if (mode == -1) return Qnil; rb_sys_fail(RSTRING_PTR(file)); |