Просмотр исходного кода

RunCommand now checks whether the process died abnormally (on Unix)

Berk Geveci 24 лет назад
Родитель
Сommit
e10cea0da4
1 измененных файлов с 41 добавлено и 2 удалено
  1. 41 2
      Source/cmSystemTools.cxx

+ 41 - 2
Source/cmSystemTools.cxx

@@ -1388,8 +1388,47 @@ bool cmSystemTools::RunCommand(const char* command,
     }
 
   retVal = pclose(cpipe);
-  retVal = WEXITSTATUS(retVal);
-  return true;
+  if (WIFEXITED(retVal))
+    {
+    retVal = WEXITSTATUS(retVal);
+    return true;
+    }
+  if (WIFSIGNALED(retVal))
+    {
+    retVal = WTERMSIG(retVal);
+    std::strstream error;
+    error << "\nProcess terminated due to ";
+    switch (retVal)
+      {
+#ifdef SIGKILL
+      case SIGKILL:
+	error << "SIGKILL";
+	break;
+#endif
+#ifdef SIGFPE
+      case SIGFPE:
+	error << "SIGFPE";
+	break;
+#endif
+#ifdef SIGBUS
+      case SIGBUS:
+	error << "SIGBUS";
+	break;
+#endif
+#ifdef SIGSEGV
+      case SIGSEGV:
+	error << "SIGSEGV";
+	break;
+#endif
+      default:
+	error << "signal " << retVal;
+	break;
+      }
+    error << std::ends;
+    output += error.str();
+    error.rdbuf()->freeze(0);
+    }
+  return false;
 #endif
 }