Utils_Locker lock(&_systemMutex);
if(command.size()<1)
throw SALOME_Exception("SystemWithPIDThreadSafe : command is expected to have a length of size 1 at least !");
+#ifndef WIN32
pid_t pid ( fork() ) ; // spawn a child process, following code is executed in both processes
+#else
+ pid_t pid = -1; //Throw SALOME_Exception on Windows
+#endif
if ( pid == 0 ) // I'm a child, replace myself with a new ompi-server
{
std::size_t sz(command.size());
#include CORBA_CLIENT_HEADER(SALOME_ExternalServerLauncher)
+#ifndef WIN32
#include <unistd.h>
+#else
+#include <windows.h>
+#include <Basics_Utils.hxx>
+#endif
#include <sstream>
#include <fstream>
#include <algorithm>
#include <memory>
+#include <functional>
constexpr char NAME_IN_NS[]="/ExternalServers";
class ChdirRAII
{
public:
+#ifndef WIN32
ChdirRAII(const std::string& wd):_wd(wd) { if(_wd.empty()) return ; char *pwd(get_current_dir_name()); _od = pwd; free(pwd); chdir(_wd.c_str()); }
~ChdirRAII() { if(_od.empty()) return ; chdir(_od.c_str()); }
+#else
+ ChdirRAII(const std::string& wd) : _wd(wd) {
+ if (_wd.empty())
+ return;
+ TCHAR pwd[MAX_PATH];
+ GetCurrentDirectory(sizeof(pwd), pwd);
+ _od = Kernel_Utils::utf8_encode_s(pwd);
+ SetCurrentDirectory(Kernel_Utils::utf8_decode_s(_wd).c_str());
+ }
+ ~ChdirRAII() {
+ if (_od.empty()) return;
+ SetCurrentDirectory(Kernel_Utils::utf8_decode_s(_od).c_str());
+ }
+#endif
private:
std::string _wd;
std::string _od;