From bc7ba7afee8ba6f7d8fe61078d4c46184dc6fa56 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Fri, 22 Apr 2022 18:47:19 +0700 Subject: MDEV-27758: Errors when building Connect engine on os x 11.6.2 Added checking for support of vfork by a platform where building being done. Set HAVE_VFORK macros in case vfork() system call is supported. Use vfork() system call if the macros HAVE_VFORK is set, else use fork(). --- config.h.cmake | 2 ++ configure.cmake | 16 ++++++++++++++++ storage/connect/tabrest.cpp | 6 +++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/config.h.cmake b/config.h.cmake index c74592b4a65..3a43c6132f0 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -577,3 +577,5 @@ #endif // !defined(__STDC_FORMAT_MACROS) #endif + +#cmakedefine HAVE_VFORK 1 diff --git a/configure.cmake b/configure.cmake index 942d5780ed9..3ac42e8e3e4 100644 --- a/configure.cmake +++ b/configure.cmake @@ -1033,3 +1033,19 @@ IF(NOT MSVC) HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE ) ENDIF() + +MY_CHECK_C_COMPILER_FLAG("-Werror") +IF(have_C__Werror) + SET(SAVE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") + CHECK_C_SOURCE_COMPILES(" + #include + int main() + { + pid_t pid=vfork(); + return (int)pid; + }" + HAVE_VFORK + ) + SET(CMAKE_REQUIRED_FLAGS ${SAVE_CMAKE_REQUIRED_FLAGS}) +ENDIF() diff --git a/storage/connect/tabrest.cpp b/storage/connect/tabrest.cpp index c66d8d76f3d..7e8b51714fb 100644 --- a/storage/connect/tabrest.cpp +++ b/storage/connect/tabrest.cpp @@ -112,7 +112,11 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename) } // endif f - pID = vfork(); +#ifdef HAVE_VFORK + pID = vfork(); +#else + pID = fork(); +#endif sprintf(fn, "-o%s", filename); if (pID == 0) { -- cgit v1.2.1