Index: /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp	(revision 30391)
+++ /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp	(revision 30392)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2007 Oracle Corporation
+ * Copyright (C) 2007-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -44,4 +44,8 @@
 # if defined(RT_OS_LINUX) /** @todo check this on solaris+freebsd as well. */
 #  include <sys/ioctl.h>
+# endif
+# if defined(RT_OS_SOLARIS) && !defined(VBOX_VBGLR3_XFREE86)
+#  define VBGL_DO_MASK_SIGNALS
+#  include <signal.h>
 # endif
 # include <errno.h>
@@ -289,4 +293,40 @@
 
 
+/*
+ * Helper macros for blocking and restoring signals.
+ */
+#ifdef VBGL_DO_MASK_SIGNALS
+# define BLOCK_SIGNALS(Prf) \
+    int         Prf##_rcSig; \
+    sigset_t    Prf##_SigSetOld; \
+    do \
+    { \
+        sigset_t Prf##_SigSetNew; \
+        sigfillset(& Prf##_SigSetNew); \
+        sigdelset(& Prf##_SigSetNew, SIGTERM); \
+        sigdelset(& Prf##_SigSetNew, SIGINT); \
+        sigdelset(& Prf##_SigSetNew, SIGHUP); \
+        sigdelset(& Prf##_SigSetNew, SIGABRT); \
+        sigdelset(& Prf##_SigSetNew, SIGKILL); \
+        Prf##_rcSig = pthread_sigmask(SIG_BLOCK, & Prf##_SigSetNew, & Prf##_SigSetOld); \
+    } while (0)
+
+# define RESTORE_SIGNALS(Prf) \
+    do \
+    { \
+        if (Prf##_rcSig == 0) \
+        { \
+            int Prf##_err = errno; /* paranoia */ \
+            pthread_sigmask(SIG_SETMASK, & Prf##_SigSetOld, NULL); \
+            errno = Prf##_err; \
+        } \
+    } while (0)
+
+#else
+# define BLOCK_SIGNALS(Prf)     do { } while (0)
+# define RESTORE_SIGNALS(Prf)   do { } while (0)
+#endif
+
+
 /**
  * Internal wrapper around various OS specific ioctl implemenations.
@@ -345,5 +385,7 @@
  *        header with an error code return field (much better alternative
  *        actually). */
+    BLOCK_SIGNALS(SigPrefix);
     int rc = ioctl((int)g_File, iFunction, &Hdr);
+    RESTORE_SIGNALS(SigPrefix);
     if (rc == -1)
     {
@@ -354,4 +396,5 @@
 
 #elif defined(RT_OS_LINUX)
+    BLOCK_SIGNALS(SigPrefix);
 # ifdef VBOX_VBGLR3_XFREE86
     int rc = xf86ioctl((int)g_File, iFunction, pvData);
@@ -359,4 +402,5 @@
     int rc = ioctl((int)g_File, iFunction, pvData);
 # endif
+    RESTORE_SIGNALS(SigPrefix);
     if (RT_LIKELY(rc == 0))
         return VINF_SUCCESS;
@@ -377,5 +421,7 @@
     /* PORTME - This is preferred over the RTFileIOCtl variant below, just be careful with the (int). */
 /** @todo test status code passing! */
+    BLOCK_SIGNALS(SigPrefix);
     int rc = xf86ioctl(g_File, iFunction, pvData);
+    RESTORE_SIGNALS(SigPrefix);
     if (rc == -1)
         return VERR_FILE_IO_ERROR;  /* This is purely legacy stuff, it has to work and no more. */
@@ -385,6 +431,8 @@
     /* Default implementation - PORTME: Do not use this without testings that passing errors works! */
 /** @todo test status code passing! */
+    BLOCK_SIGNALS(SigPrefix);
     int rc2 = VERR_INTERNAL_ERROR;
     int rc = RTFileIoCtl(g_File, (int)iFunction, pvData, cbData, &rc2);
+    RESTORE_SIGNALS(SigPrefix);
     if (RT_SUCCESS(rc))
         rc = rc2;
