ruby-changes:21512
From: akr <ko1@a...>
Date: Sun, 30 Oct 2011 07:48:54 +0900 (JST)
Subject: [ruby-changes:21512] akr:r33561 (trunk): * configure.in: check dup3.
akr 2011-10-30 07:48:41 +0900 (Sun, 30 Oct 2011) New Revision: 33561 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33561 Log: * configure.in: check dup3. * io.c (rb_cloexec_dup2): use dup3 if available. Modified files: trunk/ChangeLog trunk/configure.in trunk/io.c Index: configure.in =================================================================== --- configure.in (revision 33560) +++ configure.in (revision 33561) @@ -1351,7 +1351,8 @@ setsid telldir seekdir fchmod cosh sinh tanh log2 round\ setuid setgid daemon select_large_fdset setenv unsetenv\ mktime timegm gmtime_r clock_gettime gettimeofday poll ppoll\ - pread sendfile shutdown sigaltstack dl_iterate_phdr) + pread sendfile shutdown sigaltstack dl_iterate_phdr\ + dup3) AC_CACHE_CHECK(for unsetenv returns a value, rb_cv_unsetenv_return_value, [AC_TRY_COMPILE([ Index: ChangeLog =================================================================== --- ChangeLog (revision 33560) +++ ChangeLog (revision 33561) @@ -1,3 +1,9 @@ +Sun Oct 30 07:47:10 2011 Tanaka Akira <akr@f...> + + * configure.in: check dup3. + + * io.c (rb_cloexec_dup2): use dup3 if available. + Sat Oct 29 22:06:37 2011 Tanaka Akira <akr@f...> * include/ruby/intern.h (rb_cloexec_dup2): declared. Index: io.c =================================================================== --- io.c (revision 33560) +++ io.c (revision 33561) @@ -232,7 +232,22 @@ { int ret; +#if defined(HAVE_DUP3) && defined(O_CLOEXEC) + static int try_dup3 = 1; + if (try_dup3) { + ret = dup3(oldfd, newfd, O_CLOEXEC); + /* dup3 is available since Linux 2.6.27. */ + if (ret == -1 && errno == ENOSYS) { + try_dup3 = 0; + ret = dup2(oldfd, newfd); + } + } + else { + ret = dup2(oldfd, newfd); + } +#else ret = dup2(oldfd, newfd); +#endif if (ret == -1) return -1; fd_set_cloexec(ret); return ret; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/