[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sal/osl

Tor Lillqvist tml at iki.fi
Sat Aug 17 07:52:45 PDT 2013


 sal/osl/unx/salinit.cxx |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 8f3ce7b0a9688ebb9afee4b56de36feebd6cf091
Author: Tor Lillqvist <tml at iki.fi>
Date:   Mon Jul 29 16:50:22 2013 +0300

    Avoid crash on OS X: guarded fd exception
    
    On OS X, a file descriptor that shows up as being of type "KQUEUE" in
    lsof output is apparently created behind the scenes when starting a
    thread. (Related to BSD kernel event queues: see man kqueue.) When we
    re-exec ourselves on OS X, and then close all file descriptors >= 3,
    closing such a KQUEUE fd causes a crash.
    
    Guard against this by closing only regular files.
    
    (cherry picked from commit 73a508f574995f09559c003cb810e5d2ff2691c2)
    
    Change-Id: I5011bfbaed156b04248b6bddb2a1a58624bee3d4
    Reviewed-on: https://gerrit.libreoffice.org/5173
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>
    Reviewed-on: https://gerrit.libreoffice.org/5470

diff --git a/sal/osl/unx/salinit.cxx b/sal/osl/unx/salinit.cxx
index d880258..93c7e9d 100644
--- a/sal/osl/unx/salinit.cxx
+++ b/sal/osl/unx/salinit.cxx
@@ -23,6 +23,7 @@
 #include <cassert>
 #include <limits>
 #include <unistd.h>
+#include <sys/stat.h>
 #endif
 
 #include "osl/process.h"
@@ -54,7 +55,9 @@ void sal_detail_initialize(int argc, char ** argv) {
     }
     assert(openMax >= 0 && openMax <= std::numeric_limits< int >::max());
     for (int fd = 3; fd < openMax; ++fd) {
-        close(fd);
+        struct stat s;
+        if (fstat(fd, &s) != -1 && S_ISREG(s.st_mode))
+            close(fd);
     }
 #endif
 


More information about the Libreoffice-commits mailing list