diff --git a/CMakeLists.txt b/CMakeLists.txt index d63c9edb7..6eb2b4617 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -480,7 +480,6 @@ OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr< OPTION(OSG_USE_REF_PTR_SAFE_DEREFERENCE "Set to ON to throw an exception whenever ref_ptr<> is dereferenced or called. " OFF) OPTION(OSG_ENVVAR_SUPPORTED "Set to ON to build OpenSceneGraph with the #define OSG_ENVVAR_SUPPORTED, found in include/osg/Config, to enable use of getenv() related functions." ON) -OPTION(OSG_SYSTEM_SUPPORTED "Set to ON to build OpenSceneGraph with the #define OSG_SYSTEM_SUPPORTED, found in include/osg/Config, to enable use of system() related functions." ON) diff --git a/src/osg/Config.in b/src/osg/Config.in index 610b407df..8f4c23359 100644 --- a/src/osg/Config.in +++ b/src/osg/Config.in @@ -35,6 +35,5 @@ #cmakedefine OSG_PROVIDE_READFILE #cmakedefine OSG_USE_DEPRECATED_API #cmakedefine OSG_ENVVAR_SUPPORTED -#cmakedefine OSG_SYSTEM_SUPPORTED #endif diff --git a/src/osg/os_utils.cpp b/src/osg/os_utils.cpp index d8d881791..7689c122f 100644 --- a/src/osg/os_utils.cpp +++ b/src/osg/os_utils.cpp @@ -15,14 +15,29 @@ extern "C" { +#define USE_POSIX_SPAWN defined(__APPLE__) +//#define USE_POSIX_SPAWN true + +#if USE_POSIX_SPAWN + +#include +#include + +int osg_system(const char* command) +{ + pid_t pid; + posix_spawn(&pid, command, NULL, NULL, NULL, NULL); + return waitpid(pid, NULL, 0); +} + +#else // use tranditional C sysmtem call for osg_system implementation + int osg_system(const char* command) { -#ifdef OSG_SYSTEM_SUPPORTED return system(command); -#else - printf("osg_system(%s) not supported.\n", command); +} + #endif -} }