diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-29 22:48:41 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-29 22:48:41 +0000 |
commit | cb9f3040d7020fcac74f292eba810081b73b195e (patch) | |
tree | 0dad7014a65294ba957ba08c5260369fc09a8f9e /io.c | |
parent | 71804183a368342b45e288bb2d6f7da8d69fd75f (diff) | |
download | ruby-cb9f3040d7020fcac74f292eba810081b73b195e.tar.gz |
* configure.in: check dup3.
* io.c (rb_cloexec_dup2): use dup3 if available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -232,7 +232,22 @@ rb_cloexec_dup2(int oldfd, int newfd) { 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; |