[前][次][番号順一覧][スレッド一覧]

ruby-changes:21525

From: akr <ko1@a...>
Date: Sun, 30 Oct 2011 22:48:45 +0900 (JST)
Subject: [ruby-changes:21525] akr:r33574 (trunk): * configure.in: check pipe2.

akr	2011-10-30 22:48:35 +0900 (Sun, 30 Oct 2011)

  New Revision: 33574

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33574

  Log:
    * configure.in: check pipe2.
    
    * io.c (rb_cloexec_pipe): use pipe2 if available.

  Modified files:
    trunk/ChangeLog
    trunk/configure.in
    trunk/io.c

Index: configure.in
===================================================================
--- configure.in	(revision 33573)
+++ configure.in	(revision 33574)
@@ -1352,7 +1352,7 @@
 	      setuid setgid daemon select_large_fdset setenv unsetenv\
               mktime timegm gmtime_r clock_gettime gettimeofday poll ppoll\
               pread sendfile shutdown sigaltstack dl_iterate_phdr\
-              dup3)
+              dup3 pipe2)
 
 AC_CACHE_CHECK(for unsetenv returns a value, rb_cv_unsetenv_return_value,
   [AC_TRY_COMPILE([
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33573)
+++ ChangeLog	(revision 33574)
@@ -1,3 +1,9 @@
+Sun Oct 30 22:46:46 2011  Tanaka Akira  <akr@f...>
+
+	* configure.in: check pipe2.
+
+	* io.c (rb_cloexec_pipe): use pipe2 if available.
+
 Sun Oct 30 22:32:44 2011  Tanaka Akira  <akr@f...>
 
 	* ruby.c (fill_standard_fds): use fstat() instead of fcntl(F_GETFD)
Index: io.c
===================================================================
--- io.c	(revision 33573)
+++ io.c	(revision 33574)
@@ -266,7 +266,25 @@
 rb_cloexec_pipe(int fildes[2])
 {
     int ret;
+
+#if defined(HAVE_PIPE2)
+    static int try_pipe2 = 1;
+    if (try_pipe2) {
+        ret = pipe2(fildes, O_CLOEXEC);
+        if (ret != -1)
+            return ret;
+        /* pipe2 is available since Linux 2.6.27. */
+        if (errno == ENOSYS) {
+            try_pipe2 = 0;
+            ret = pipe(fildes);
+        }
+    }
+    else {
+        ret = pipe(fildes);
+    }
+#else
     ret = pipe(fildes);
+#endif
     if (ret == -1) return -1;
 #ifdef __CYGWIN__
     if (ret == 0 && fildes[1] == -1) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]