Add closefrom call to RunProcess

This commit is contained in:
Jack Andersen 2019-02-26 19:13:19 -10:00
parent 6626557cc4
commit 1f04f7ae12
6 changed files with 9 additions and 10 deletions

View File

@ -9,6 +9,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <sys/statvfs.h> #include <sys/statvfs.h>
#if __linux__ || __APPLE__
extern "C" int rep_closefrom(int lower);
#define closefrom rep_closefrom
#endif
#else #else
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1 #define WIN32_LEAN_AND_MEAN 1

View File

@ -3,8 +3,4 @@ set(BLENDER_SOURCES
SDNARead.cpp SDNARead.cpp
HMDL.cpp) HMDL.cpp)
if(UNIX)
list(APPEND BLENDER_SOURCES closefrom.c)
endif()
hecl_add_list(Blender BLENDER_SOURCES) hecl_add_list(Blender BLENDER_SOURCES)

View File

@ -20,12 +20,6 @@
#if _WIN32 #if _WIN32
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#else
#include <unistd.h>
#if __linux__ || __APPLE__
extern "C" int rep_closefrom(int lower);
#define closefrom rep_closefrom
#endif
#endif #endif
#undef min #undef min

View File

@ -75,6 +75,10 @@ set(COMMON_SOURCES
atdna_Frontend.cpp atdna_Frontend.cpp
atdna_CVar.cpp) atdna_CVar.cpp)
if(UNIX)
list(APPEND PLAT_SRCS closefrom.c)
endif()
add_library(hecl-full add_library(hecl-full
${BACKEND_SOURCES} ${BACKEND_SOURCES}
${FRONTEND_SOURCES} ${FRONTEND_SOURCES}

View File

@ -853,6 +853,7 @@ int RunProcess(const SystemChar* path, const SystemChar* const args[]) {
#else #else
pid_t pid = fork(); pid_t pid = fork();
if (!pid) { if (!pid) {
closefrom(3);
execvp(path, (char* const*)args); execvp(path, (char* const*)args);
exit(1); exit(1);
} }