Salome HOME
projects
/
modules
/
kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[EDF29150] : head monitoring file management
[modules/kernel.git]
/
src
/
Basics
/
Monitoring.cxx
diff --git
a/src/Basics/Monitoring.cxx
b/src/Basics/Monitoring.cxx
index 690490c04046d23a7ea9b3897c48201b408b36d0..85247479c6745946c2c62a3299d6974517f85c18 100644
(file)
--- a/
src/Basics/Monitoring.cxx
+++ b/
src/Basics/Monitoring.cxx
@@
-44,14
+44,10
@@
#include <signal.h>
#endif
#include <signal.h>
#endif
-static std::string _out_filename;
#ifndef WIN32
#ifndef WIN32
-static pid_t pid_of_subprocess = 0;
-#endif
-
-#ifndef WIN32
-static void LaunchMonitoringLinux(const std::string& pyScriptToEvaluate, const std::string& outFileName)
+static long LaunchMonitoringLinux(const std::string& pyScriptToEvaluate)
{
{
+ pid_t pid_of_subprocess = 0;
constexpr char PYTHON_EXEC[] = "python3";
pid_t pid = fork();
if (pid == -1)
constexpr char PYTHON_EXEC[] = "python3";
pid_t pid = fork();
if (pid == -1)
@@
-69,14
+65,14
@@
static void LaunchMonitoringLinux(const std::string& pyScriptToEvaluate, const s
{
pid_of_subprocess = pid;
}
{
pid_of_subprocess = pid;
}
+ return pid_of_subprocess;
}
#endif
}
#endif
-
void SALOME::LaunchMonitoring(const std::string& pyScriptToEvaluate, const std::string& outFileNam
e)
+
long SALOME::LaunchMonitoring(const std::string& pyScriptToEvaluat
e)
{
{
- _out_filename = outFileName;
#ifndef WIN32
#ifndef WIN32
-
LaunchMonitoringLinux(pyScriptToEvaluate,outFileNam
e);
+
return LaunchMonitoringLinux(pyScriptToEvaluat
e);
#else
throw std::runtime_error("LaunchMonitoring not implemented for Windows !");
#endif
#else
throw std::runtime_error("LaunchMonitoring not implemented for Windows !");
#endif
@@
-88,7
+84,7
@@
std::vector<double> SALOME::ReadFloatsInFile(const std::string& fileName)
if(!inputFile.is_open())
{
if(!inputFile.is_open())
{
- std::ostringstream oss; oss << "Impossible to open file \"" <<
_out_filename
<< "\" !";
+ std::ostringstream oss; oss << "Impossible to open file \"" <<
fileName
<< "\" !";
throw std::runtime_error( oss.str() );
}
std::vector<double> ret;
throw std::runtime_error( oss.str() );
}
std::vector<double> ret;
@@
-114,25
+110,17
@@
std::vector<double> SALOME::ReadFloatsInFile(const std::string& fileName)
}
#ifndef WIN32
}
#ifndef WIN32
-static
std::vector<double> StopMonitoringLinux(
)
+static
void StopMonitoringLinux(long pid
)
{
{
+ pid_t pid_of_subprocess = (pid_t) pid;
kill( pid_of_subprocess, SIGTERM );
kill( pid_of_subprocess, SIGTERM );
- std::vector<double> ret;
- try
- {
- ret = SALOME::ReadFloatsInFile( _out_filename );
- }
- catch(std::exception& e) { }
- pid_of_subprocess = 0;
- _out_filename.clear();
- return ret;
}
#endif
}
#endif
-
std::vector<double> SALOME::StopMonitoring(
)
+
void SALOME::StopMonitoring(long pid
)
{
#ifndef WIN32
{
#ifndef WIN32
- return StopMonitoringLinux();
+ return StopMonitoringLinux(
pid
);
#else
throw std::runtime_error("StopMonitoring not implemented for Windows !");
#endif
#else
throw std::runtime_error("StopMonitoring not implemented for Windows !");
#endif