[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp

Henry Castro hcastro at collabora.com
Tue Feb 2 02:23:53 UTC 2016


 loolwsd/Util.cpp |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 loolwsd/Util.hpp |   19 +++++++++++++++++++
 2 files changed, 71 insertions(+)

New commits:
commit 1b6425913d475a2b15866876fe50a9e58a0ea2ce
Author: Henry Castro <hcastro at collabora.com>
Date:   Mon Feb 1 22:23:58 2016 -0400

    loolwsd: add LO core exit codes

diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index 088620c..a764ff4 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -491,6 +491,58 @@ namespace Util
         sigaction(SIGFPE, &aSigAction, NULL);
 #endif
     }
+
+    int getChildStatus(const int nCode)
+    {
+        int nRetVal;
+
+        switch (static_cast<const LOOLExitCode>(nCode))
+        {
+            case LOOLExitCode::LOOL_SECOND_OFFICE:
+            case LOOLExitCode::LOOL_FATAL_ERROR:
+            case LOOLExitCode::LOOL_CRASH_WITH_RESTART:
+            case LOOLExitCode::LOOL_NORMAL_RESTART:
+            case LOOLExitCode::LOOL_EXIT_SOFTWARE:
+                nRetVal = EXIT_FAILURE;
+            break;
+
+            case LOOLExitCode::LOOL_NO_ERROR:
+                nRetVal = EXIT_SUCCESS;
+            break;
+
+            default:
+                nRetVal = EXIT_SUCCESS;
+            break;
+        }
+
+        return nRetVal;
+    }
+
+    int getSignalStatus(const int nCode)
+    {
+        int nRetVal;
+
+        switch (nCode)
+        {
+            case SIGSEGV:
+            case SIGBUS:
+            case SIGABRT:
+            case SIGILL:
+            case SIGFPE:
+            case SIGTERM:
+            case SIGINT:
+            case SIGQUIT:
+            case SIGHUP:
+                nRetVal = EXIT_FAILURE;
+            break;
+
+            default:
+                nRetVal = EXIT_SUCCESS;
+            break;
+        }
+
+        return nRetVal;
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp
index b599508..b6f6f08 100644
--- a/loolwsd/Util.hpp
+++ b/loolwsd/Util.hpp
@@ -25,6 +25,22 @@
 
 // Possible states of LOOL processes.
 enum class LOOLState { LOOL_RUNNING, LOOL_STOPPING, LOOL_ABNORMAL };
+
+enum class LOOLExitCode
+{
+    LOOL_NO_ERROR = 0,
+    /* pipe was detected - second office must terminate itself */
+    LOOL_SECOND_OFFICE = 1,
+    /* an uno exception was catched during startup */
+    LOOL_FATAL_ERROR = 77, /* Only the low 8 bits are significant 333 % 256 = 77 */
+    /* user force automatic restart after crash */
+    LOOL_CRASH_WITH_RESTART = 79,
+    /* the office restarts itself */
+    LOOL_NORMAL_RESTART = 81,
+    /* internal software error */
+    LOOL_EXIT_SOFTWARE = 70
+};
+
 extern volatile LOOLState TerminationState;
 
 /// Flag to stop pump loops.
@@ -100,6 +116,9 @@ namespace Util
     /// Trap signals to cleanup and exit the process gracefully.
     void setTerminationSignals();
     void setFatalSignals();
+
+    int getChildStatus(const int nCode);
+    int getSignalStatus(const int nCode);
 };
 
 //TODO: Move to own file.


More information about the Libreoffice-commits mailing list