diff --git a/hecl/include/hecl/hecl.hpp b/hecl/include/hecl/hecl.hpp index e7f693b6b..8bf44193f 100644 --- a/hecl/include/hecl/hecl.hpp +++ b/hecl/include/hecl/hecl.hpp @@ -9,6 +9,10 @@ #include #include #include +#if __linux__ || __APPLE__ +extern "C" int rep_closefrom(int lower); +#define closefrom rep_closefrom +#endif #else #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 diff --git a/hecl/lib/Blender/CMakeLists.txt b/hecl/lib/Blender/CMakeLists.txt index c77da6a49..c21e64cce 100644 --- a/hecl/lib/Blender/CMakeLists.txt +++ b/hecl/lib/Blender/CMakeLists.txt @@ -3,8 +3,4 @@ set(BLENDER_SOURCES SDNARead.cpp HMDL.cpp) -if(UNIX) - list(APPEND BLENDER_SOURCES closefrom.c) -endif() - hecl_add_list(Blender BLENDER_SOURCES) diff --git a/hecl/lib/Blender/Connection.cpp b/hecl/lib/Blender/Connection.cpp index c573abe59..13ed12385 100644 --- a/hecl/lib/Blender/Connection.cpp +++ b/hecl/lib/Blender/Connection.cpp @@ -20,12 +20,6 @@ #if _WIN32 #include #include -#else -#include -#if __linux__ || __APPLE__ -extern "C" int rep_closefrom(int lower); -#define closefrom rep_closefrom -#endif #endif #undef min diff --git a/hecl/lib/CMakeLists.txt b/hecl/lib/CMakeLists.txt index 8b8b6f1a4..13cba12c6 100644 --- a/hecl/lib/CMakeLists.txt +++ b/hecl/lib/CMakeLists.txt @@ -75,6 +75,10 @@ set(COMMON_SOURCES atdna_Frontend.cpp atdna_CVar.cpp) +if(UNIX) + list(APPEND PLAT_SRCS closefrom.c) +endif() + add_library(hecl-full ${BACKEND_SOURCES} ${FRONTEND_SOURCES} diff --git a/hecl/lib/Blender/closefrom.c b/hecl/lib/closefrom.c similarity index 100% rename from hecl/lib/Blender/closefrom.c rename to hecl/lib/closefrom.c diff --git a/hecl/lib/hecl.cpp b/hecl/lib/hecl.cpp index f85c1baef..e52ca5459 100644 --- a/hecl/lib/hecl.cpp +++ b/hecl/lib/hecl.cpp @@ -853,6 +853,7 @@ int RunProcess(const SystemChar* path, const SystemChar* const args[]) { #else pid_t pid = fork(); if (!pid) { + closefrom(3); execvp(path, (char* const*)args); exit(1); }