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

Henry Castro hcastro at collabora.com
Thu Jul 16 15:08:05 PDT 2015


 loolwsd/LOOLWSD.cpp |   41 +++++++++++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 12 deletions(-)

New commits:
commit 061a2bfc3dd2057abdc3b517189d3ee012b9bf46
Author: Henry Castro <hcastro at collabora.com>
Date:   Thu Jul 16 18:05:28 2015 -0400

    loolwsd: rework child monitor status.

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index f6b8457..e5be693 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1018,25 +1018,42 @@ void LOOLWSD::desktopMain()
 
     namedMutexLOOL.unlock();
 
+    /* Pause for a second */
+    sleep(1);
+
     while (MasterProcessSession::_childProcesses.size() > 0)
     {
         int status;
         pid_t pid = waitpid(-1, &status, WUNTRACED | WNOHANG);
-        if (pid < 0)
+        if (pid > 0)
         {
-            if (errno == ECHILD)
+            if ( MasterProcessSession::_childProcesses.find(pid) != MasterProcessSession::_childProcesses.end() )
             {
-                // We have spawned children, and we think that we still have them running,
-                // but we don't, huh? Something badly messed up, or just a timing glitch,
-                // like we are at the moment in the process of spawning new children?
-                // Sleep or return from the function (i.e. finish the Undertaker thread)?
-                std::cout << Util::logPrefix() << "No child processes even if we think there should be some!?" << std::endl;
-             }
-        }
+                if ((WIFEXITED(status) || WIFSIGNALED(status) || WTERMSIG(status) ) )
+                {
+                    std::cout << Util::logPrefix() << "One of our known child processes died :" << std::to_string(pid)  << std::endl;
+                    MasterProcessSession::_childProcesses.erase(pid);
+                }
+
+                if ( WCOREDUMP(status) )
+                    std::cout << Util::logPrefix() << "The child produced a core dump." << std::endl;
+
+                if ( WIFSTOPPED(status) )
+                    std::cout << Util::logPrefix() << "The child process was stopped by delivery of a signal." << std::endl;
 
-        if ((WIFEXITED(status) || WIFSIGNALED(status) || WTERMSIG(status) ) &&
-            MasterProcessSession::_childProcesses.find(pid) != MasterProcessSession::_childProcesses.end())
-            std::cout << Util::logPrefix() << "One of our known child processes died" << std::endl;
+                if ( WSTOPSIG(status) )
+                    std::cout << Util::logPrefix() << "The child process was stopped." << std::endl;
+
+                if ( WIFCONTINUED(status) )
+                    std::cout << Util::logPrefix() << "The child process was resumed." << std::endl;
+            }
+            else
+            {
+                std::cout << Util::logPrefix() << "None of our known child processes died :" << std::to_string(pid)  << std::endl;
+            }
+        }
+        else if (pid < 0)
+            std::cout << Util::logPrefix() << "Child error: " << strerror(errno);
 
         if (MasterProcessSession::getAvailableChildSessions() == 0 && MasterProcessSession::getPendingPreSpawnedChildren() == 0 )
         {


More information about the Libreoffice-commits mailing list