pipe2 is not available in older kernels and glibc
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 22 Mar 2011 10:45:29 +0000 (11:45 +0100)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 16 May 2011 11:53:59 +0000 (13:53 +0200)
CMakeLists.txt
zypp/ExternalProgram.cc

index 83fad9e..f3e33cb 100644 (file)
@@ -39,6 +39,12 @@ IF(${CXX_FORMAT_SECURITY})
   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=format-security")
 ENDIF(${CXX_FORMAT_SECURITY})
 
+INCLUDE(CheckFunctionExists)
+CHECK_FUNCTION_EXISTS(pipe2 PIPE2_FOUND)
+IF(${PIPE2_FOUND})
+  ADD_DEFINITIONS(-DHAVE_PIPE2)
+ENDIF(${PIPE2_FOUND})
+
 ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
 ADD_DEFINITIONS( -DVERSION="${VERSION}" )
 SET( LIBZYPP_VERSION_INFO "${LIBZYPP_SO_FIRST}.${LIBZYPP_AGE}.${LIBZYPP_PATCH}" )
index 35c903a..c319192 100644 (file)
@@ -572,7 +572,13 @@ namespace zypp {
       EarlyPipe::EarlyPipe()
       {
        _fds[R] = _fds[W] = -1;
+#ifdef HAVE_PIPE2
        ::pipe2( _fds, O_NONBLOCK );
+#else
+        ::pipe( _fds );
+        ::fcntl(_fds[R], F_SETFD, O_NONBLOCK );
+        ::fcntl(_fds[W], F_SETFD, O_NONBLOCK );
+#endif
        _stderr = ::fdopen( _fds[R], "r" );
       }