sal/osl/unx/salinit.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
New commits: commit 3ec3ef25217bd6f47c80630387dca4b05e402b8d Author: Tor Lillqvist <t...@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 <fridr...@documentfoundation.org> Tested-by: Fridrich Strba <fridr...@documentfoundation.org> diff --git a/sal/osl/unx/salinit.cxx b/sal/osl/unx/salinit.cxx index 327ca0e..99cde2d 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" @@ -61,7 +62,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 #if HAVE_SYSLOG_H _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits