]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Compilation on Windows. EMC2P_V1_1_0
authorrnv <rnv@opencascade.com>
Wed, 19 Jun 2019 12:27:06 +0000 (15:27 +0300)
committerrnv <rnv@opencascade.com>
Wed, 19 Jun 2019 12:27:06 +0000 (15:27 +0300)
src/Container/SALOME_ContainerManager.cxx
src/Launcher/SALOME_ExternalServerLauncher.cxx

index 608fda19d53d5b3477825ecd53ed604fe56e7837..7e2f7c6c90f8ce0b524d4202b9a463ecd0239674 100644 (file)
@@ -1404,7 +1404,11 @@ long SALOME_ContainerManager::SystemWithPIDThreadSafe(const std::vector<std::str
   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());
index 2f2bc73d49329c09dc6461dd8c6f5be115c3d3b6..4574819ee72f3aec16f4458b73b489a4537e1d07 100644 (file)
 
 #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";
 
@@ -55,8 +61,23 @@ SALOME_ExternalServerLauncher::~SALOME_ExternalServerLauncher()
 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;