interface ExternalServerLauncher
{
- ExternalServerHandler launchServer( in string server_name, in CmdList command_list ) raises(SALOME::SALOME_Exception);
+ ExternalServerHandler launchServer( in string server_name, in string working_dir, in CmdList command_list ) raises(SALOME::SALOME_Exception);
void cleanServersInNS();
StringVec listServersInNS();
ExternalServerHandler retrieveServerRefGivenNSEntry( in string ns_entry ) raises(SALOME::SALOME_Exception);
#include CORBA_CLIENT_HEADER(SALOME_ExternalServerLauncher)
+#include <unistd.h>
+
#include <sstream>
#include <algorithm>
delete _NS;
}
-SALOME::ExternalServerHandler_ptr SALOME_ExternalServerLauncher::launchServer(const char *server_name, const SALOME::CmdList& command_list )
+class ChdirRAII
+{
+public:
+ 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()); }
+private:
+ std::string _wd;
+ std::string _od;
+};
+
+SALOME::ExternalServerHandler_ptr SALOME_ExternalServerLauncher::launchServer(const char *server_name, const char *working_dir, const SALOME::CmdList& command_list )
{
std::vector<std::string> servers(ListOfExternalServersCpp(_NS));
if(std::find(servers.begin(),servers.end(),server_name)!=servers.end())
long pid(0);
try
{
+ ChdirRAII cr(working_dir);
pid = SALOME_ContainerManager::SystemWithPIDThreadSafe(cmd) ;
}
catch(SALOME_Exception& e)
SALOME_ExternalServerLauncher(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, PortableServer::POA_var poa);
virtual ~SALOME_ExternalServerLauncher();
public:
- SALOME::ExternalServerHandler_ptr launchServer(const char *server_name, const SALOME::CmdList& command_list ) override;
+ SALOME::ExternalServerHandler_ptr launchServer(const char *server_name, const char *working_dir, const SALOME::CmdList& command_list ) override;
void registerToKill(const char *server_name, CORBA::Long PID) override;
void cleanServersInNS() override;
void shutdownServers() override;