From: Gunnar Beutner Date: Wed, 3 Sep 2014 06:10:55 +0000 (+0200) Subject: Implement support for systems where pipe2 returns ENOSYS X-Git-Tag: v2.1.1~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=039a13cf88a597050215541d65272c4784423b1a;p=icinga2 Implement support for systems where pipe2 returns ENOSYS fixes #7065 fixes #6696 --- diff --git a/lib/base/process.cpp b/lib/base/process.cpp index 46de69601..96efbb080 100644 --- a/lib/base/process.cpp +++ b/lib/base/process.cpp @@ -71,23 +71,24 @@ void Process::StaticInitialize(void) #else /* _WIN32 */ # ifdef HAVE_PIPE2 if (pipe2(l_EventFDs[tid], O_CLOEXEC) < 0) { - BOOST_THROW_EXCEPTION(posix_error() - << boost::errinfo_api_function("pipe2") - << boost::errinfo_errno(errno)); - } -# else /* HAVE_PIPE2 */ - if (pipe(l_EventFDs[tid]) < 0) { - BOOST_THROW_EXCEPTION(posix_error() - << boost::errinfo_api_function("pipe") - << boost::errinfo_errno(errno)); - } - - Utility::SetCloExec(l_EventFDs[tid][0]); - Utility::SetCloExec(l_EventFDs[tid][1]); + if (errno == ENOSYS) { # endif /* HAVE_PIPE2 */ + if (pipe(l_EventFDs[tid]) < 0) { + BOOST_THROW_EXCEPTION(posix_error() + << boost::errinfo_api_function("pipe") + << boost::errinfo_errno(errno)); + } - Utility::SetNonBlocking(l_EventFDs[tid][0]); - Utility::SetNonBlocking(l_EventFDs[tid][1]); + Utility::SetCloExec(l_EventFDs[tid][0]); + Utility::SetCloExec(l_EventFDs[tid][1]); +# ifdef HAVE_PIPE2 + } else { + BOOST_THROW_EXCEPTION(posix_error() + << boost::errinfo_api_function("pipe2") + << boost::errinfo_errno(errno)); + } + } +# endif /* HAVE_PIPE2 */ #endif /* _WIN32 */ } } @@ -444,19 +445,23 @@ void Process::Run(const boost::function& callback) #ifdef HAVE_PIPE2 if (pipe2(fds, O_CLOEXEC) < 0) { - BOOST_THROW_EXCEPTION(posix_error() - << boost::errinfo_api_function("pipe2") - << boost::errinfo_errno(errno)); - } -#else /* HAVE_PIPE2 */ - if (pipe(fds) < 0) { - BOOST_THROW_EXCEPTION(posix_error() - << boost::errinfo_api_function("pipe") - << boost::errinfo_errno(errno)); - } + if (errno == ENOSYS) { +#endif /* HAVE_PIPE2 */ + if (pipe(fds) < 0) { + BOOST_THROW_EXCEPTION(posix_error() + << boost::errinfo_api_function("pipe") + << boost::errinfo_errno(errno)); + } - Utility::SetCloExec(fds[0]); - Utility::SetCloExec(fds[1]); + Utility::SetCloExec(fds[0]); + Utility::SetCloExec(fds[1]); +#ifdef HAVE_PIPE2 + } else { + BOOST_THROW_EXCEPTION(posix_error() + << boost::errinfo_api_function("pipe2") + << boost::errinfo_errno(errno)); + } + } #endif /* HAVE_PIPE2 */ // build argv