diff --git a/Test/Applications/x2tTester/README.md b/Test/Applications/x2tTester/README.md
index 0bcc065dd5..1bf740cadf 100644
--- a/Test/Applications/x2tTester/README.md
+++ b/Test/Applications/x2tTester/README.md
@@ -51,7 +51,7 @@ You need to create an xml configuration file. It must contain:
# (non-required) default unicode code delimiter for csv files, if filenameCsvTxtParams is 0, or no param in filename (default - 3b)
- # (non-required) timeout in milliseconds (default - 300000 (5 min))
+ # (non-required) timeout in seconds (default - 300 (5 min))
# (non-required) path to xml file with a list of input files
diff --git a/Test/Applications/x2tTester/x2tTester.cpp b/Test/Applications/x2tTester/x2tTester.cpp
index be9dae2c0b..16bf48f022 100644
--- a/Test/Applications/x2tTester/x2tTester.cpp
+++ b/Test/Applications/x2tTester/x2tTester.cpp
@@ -209,7 +209,7 @@ Cx2tTester::Cx2tTester(const std::wstring& configPath)
m_defaultCsvTxtEndcoding = L"UTF-8";
m_inputFormatsList.SetDefault();
m_outputFormatsList.SetOutput();
- m_timeout = 5 * 60 * 1000; // 5 min
+ m_timeout = 5 * 60; // 5 min
SetConfig(configPath);
m_errorsXmlDirectory = m_outputDirectory + FILE_SEPARATOR_STR + L"_errors";
diff --git a/X2tConverter/src/run.h b/X2tConverter/src/run.h
index 207c9abb7a..a0f4d10c4a 100644
--- a/X2tConverter/src/run.h
+++ b/X2tConverter/src/run.h
@@ -39,12 +39,13 @@
#ifdef _LINUX
#include
#include
+#include
#include
#endif
namespace NSX2T
{
- int Convert(const std::wstring& sConverterDirectory, const std::wstring sXmlPath, unsigned long nTimeout = 0, bool *nOutWaitResult = nullptr)
+ int Convert(const std::wstring& sConverterDirectory, const std::wstring sXmlPath, unsigned long nTimeout = 0, bool *bOutWaitResult = nullptr)
{
int nReturnCode = 0;
std::wstring sConverterExe = sConverterDirectory + L"/x2t";
@@ -96,11 +97,11 @@ namespace NSX2T
if(nTimeout == 0)
nTimeout = INFINITE;
- DWORD nWaitResult = WaitForSingleObject(processinfo.hProcess, nTimeout);
+ DWORD nWaitResult = WaitForSingleObject(processinfo.hProcess, nTimeout * 1000);
// true if timeout
- if(nOutWaitResult != nullptr)
- *nOutWaitResult = (bool)nWaitResult;
+ if(bOutWaitResult != nullptr)
+ *bOutWaitResult = (bool)nWaitResult;
RELEASEARRAYOBJECTS(pCommandLine);
@@ -163,6 +164,12 @@ namespace NSX2T
nenv[1] = sPATH.c_str();
nenv[2] = NULL;
#endif
+ if(nTimeout != 0)
+ {
+ // 5 secs to send signal etc...
+ rlimit limit = {nTimeout, nTimeout + 5};
+ setrlimit(RLIMIT_CPU, &limit);
+ }
execve(sProgramm.c_str(),
(char * const *)nargs,
@@ -171,9 +178,13 @@ namespace NSX2T
break;
}
default: // parent process, pid now contains the child pid
- while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
+
+ // wait for child to complete
+ while (-1 == waitpid(pid, &status, 0));
if(WIFSIGNALED(status))
{
+ if(bOutWaitResult != nullptr && WTERMSIG(status) == SIGXCPU)
+ *bOutWaitResult = true;
nReturnCode = status;
}
else if (WIFEXITED(status))