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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu Jan 21 07:42:43 PST 2016


 loolwsd/LOOLWSD.cpp |   50 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 15 deletions(-)

New commits:
commit 8e8e7c70c275c8942d8481b76f52e8f4ef6f260b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Thu Jan 14 22:31:02 2016 -0500

    loolwsd: cleanup and correction of child signal handling
    
    Change-Id: I8739e71a2180c970ba4b8eb3b1d4721ecf4268e9
    Reviewed-on: https://gerrit.libreoffice.org/21670
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index f629d8e..98adeb0 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -954,28 +954,48 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
     unsigned timeoutCounter = 0;
     while (!TerminationFlag && !LOOLWSD::DoTest && MasterProcessSession::ChildProcesses.size() > 0)
     {
-        pid_t pid = waitpid(-1, &status, WUNTRACED | WNOHANG);
+        const pid_t pid = waitpid(-1, &status, WUNTRACED | WNOHANG);
         if (pid > 0)
         {
             if ( MasterProcessSession::ChildProcesses.find(pid) != MasterProcessSession::ChildProcesses.end() )
             {
-                if ((WIFEXITED(status) || WIFSIGNALED(status) || WTERMSIG(status) ) )
+                if (WIFEXITED(status))
                 {
-                    Log::error("Child [" + std::to_string(pid) + "] processes died.");
+                    Log::info() << "Child process [" << pid << "] exited with code: "
+                                << WEXITSTATUS(status) << "." << Log::end;
+
                     MasterProcessSession::ChildProcesses.erase(pid);
                 }
+                else
+                if (WIFSIGNALED(status))
+                {
+                    std::string fate = "died";
+#ifdef WCOREDUMP
+                    if (WCOREDUMP(status))
+                        fate = "core-dumped";
+#endif
+                    Log::error() << "Child process [" << pid << "] " << fate
+                                 << " with " << Util::signalName(WTERMSIG(status))
+                                 << " signal. " << Log::end;
 
-                if ( WCOREDUMP(status) )
-                    Log::error("Child [" + std::to_string(pid) + "] produced a core dump.");
-
-                if ( WIFSTOPPED(status) )
-                    Log::error("Child [" + std::to_string(pid) + "] process was stopped by delivery of a signal.");
-
-                if ( WSTOPSIG(status) )
-                    Log::error("Child [" + std::to_string(pid) + "] process was stopped.");
-
-                if ( WIFCONTINUED(status) )
-                    Log::error("Child [" + std::to_string(pid) + "] process was resumed.");
+                    MasterProcessSession::ChildProcesses.erase(pid);
+                }
+                else if (WIFSTOPPED(status))
+                {
+                    Log::info() << "Child process [" << pid << "] stopped with "
+                                << Util::signalName(WSTOPSIG(status))
+                                << " signal. " << Log::end;
+                }
+                else if (WIFCONTINUED(status))
+                {
+                    Log::info() << "Child process [" << pid << "] resumed with SIGCONT."
+                                << Log::end;
+                }
+                else
+                {
+                    Log::warn() << "Unknown status returned by waitpid: "
+                                << std::hex << status << "." << Log::end;
+                }
             }
             else
             {
@@ -983,7 +1003,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
             }
         }
         else if (pid < 0)
-            Log::error("Error: Child error.");
+            Log::error("Error: waitpid failed.");
 
         if (timeoutCounter++ == INTERVAL_PROBES)
         {


More information about the Libreoffice-commits mailing list