ruby-changes:21522
From: akr <ko1@a...>
Date: Sun, 30 Oct 2011 20:07:20 +0900 (JST)
Subject: [ruby-changes:21522] akr:r33571 (trunk): * io.c (rb_cloexec_dup): refine control flow.
akr 2011-10-30 20:07:09 +0900 (Sun, 30 Oct 2011) New Revision: 33571 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33571 Log: * io.c (rb_cloexec_dup): refine control flow. (rb_cloexec_dup2): ditto. Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33570) +++ ChangeLog (revision 33571) @@ -1,3 +1,8 @@ +Sun Oct 30 20:06:07 2011 Tanaka Akira <akr@f...> + + * io.c (rb_cloexec_dup): refine control flow. + (rb_cloexec_dup2): ditto. + Sun Oct 30 18:45:50 2011 Tanaka Akira <akr@f...> * ruby.c (fill_standard_fds): new function to open closed standard Index: io.c =================================================================== --- io.c (revision 33570) +++ io.c (revision 33571) @@ -212,14 +212,13 @@ if (try_fcntl) { /* don't allocate standard file descriptors: 0, 1, 2 */ ret = fcntl(oldfd, F_DUPFD_CLOEXEC, 3); + if (ret != -1) + return ret; /* F_DUPFD_CLOEXEC is available since Linux 2.6.24. Linux 2.6.18 fails with EINVAL */ - if (ret == -1 && errno == EINVAL) { + if (errno == EINVAL) { try_fcntl = 0; ret = dup(oldfd); } - else { - return ret; - } } else { ret = dup(oldfd); @@ -244,14 +243,13 @@ static int try_dup3 = 1; if (2 < newfd && try_dup3) { ret = dup3(oldfd, newfd, O_CLOEXEC); + if (ret != -1) + return ret; /* dup3 is available since Linux 2.6.27. */ - if (ret == -1 && errno == ENOSYS) { + if (errno == ENOSYS) { try_dup3 = 0; ret = dup2(oldfd, newfd); } - else { - return ret; - } } else { ret = dup2(oldfd, newfd); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/