ruby-changes:21537
From: akr <ko1@a...>
Date: Mon, 31 Oct 2011 22:07:37 +0900 (JST)
Subject: [ruby-changes:21537] akr:r33586 (trunk): * ext/dbm/dbm.c (fdbm_initialize): use O_CLOEXEC if available.
akr 2011-10-31 22:07:26 +0900 (Mon, 31 Oct 2011) New Revision: 33586 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33586 Log: * ext/dbm/dbm.c (fdbm_initialize): use O_CLOEXEC if available. Modified files: trunk/ChangeLog trunk/ext/dbm/dbm.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33585) +++ ChangeLog (revision 33586) @@ -1,3 +1,7 @@ +Mon Oct 31 22:04:54 2011 Tanaka Akira <akr@f...> + + * ext/dbm/dbm.c (fdbm_initialize): use O_CLOEXEC if available. + Mon Oct 31 21:47:48 2011 Tanaka Akira <akr@f...> * include/ruby/intern.h (rb_fd_fix_cloexec): renamed from Index: ext/dbm/dbm.c =================================================================== --- ext/dbm/dbm.c (revision 33585) +++ ext/dbm/dbm.c (revision 33586) @@ -137,20 +137,23 @@ 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); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/