X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Ftesting%2FTestStep.cpp;fp=example%2Fdiameter%2Flauncher%2Ftesting%2FTestStep.cpp;h=b1da8fb1a3b248fee3450e5daa11c43266c199ea;hb=f92f99bd9a76474ef38c0437a181bfb0a0e14262;hp=605407e8978830b51b5c40079e92c34daed0903a;hpb=eb1546671c9e29befae4bd5052de9ee804b1a389;p=anna.git diff --git a/example/diameter/launcher/testing/TestStep.cpp b/example/diameter/launcher/testing/TestStep.cpp index 605407e..b1da8fb 100644 --- a/example/diameter/launcher/testing/TestStep.cpp +++ b/example/diameter/launcher/testing/TestStep.cpp @@ -10,6 +10,7 @@ #include #include #include +#include // Project #include @@ -34,7 +35,21 @@ namespace { void cmdRunOnThread (TestStepCmd *step, const std::string &cmd) { step->setThreadRunning(true); int rc = system(cmd.c_str()); - if (rc != -1) rc >>= 8; // divide by 256 + if (rc < 0 && errno == ECHILD) rc = 0; // ignore, it could happens + // I know one reason for this is that SICCHLD is set to SIG_IGN but this + // should not be the case here. SIGCHLD is explicity set to SIG_DFL + // using a sigaction before the call to system(). (Although it is + // normally set to SIG_IGN). There should not be any other threads + // messing about with SIGCHLD. + + if (rc < 0) { + step->setErrorMsg(anna::functions::asString("errno = %d", errno)); + //std::terminate; + } + else { + rc >>= 8; // divide by 256 + } + step->setResultCode(rc); step->complete(); // TODO: timeout the system call @@ -422,6 +437,7 @@ throw() { result->createAttribute("Script", (a_script != "") ? a_script:""); result->createAttribute("Parameters", (a_parameters != "") ? a_parameters:""); result->createAttribute("CommandInProgress", a_threadRunning ? "yes":"no"); + if (a_errorMsg != "") result->createAttribute("ErrorMessage", a_errorMsg); if (!a_threadRunning && a_resultCode != -2) { result->createAttribute("ResultCode", a_resultCode); //if (a_output != "") result->createAttribute("Output", a_output);