Index: /trunk/include/iprt/process.h
===================================================================
--- /trunk/include/iprt/process.h	(revision 33043)
+++ /trunk/include/iprt/process.h	(revision 33044)
@@ -4,5 +4,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -187,9 +187,4 @@
 #define RTPROC_FLAGS_DETACHED               RT_BIT(0)
 
-/** Daemonize the child process, without changing the directory.
- * @deprecated Dont use this for new code, it is not portable.  Use
- *             RTProcDaemonize instead. */
-#define RTPROC_FLAGS_DAEMONIZE_DEPRECATED   RT_BIT(1)
-
 /** Use special code path for starting child processes from
  * a service (daemon). On Windows this is required for services
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 33043)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 33044)
@@ -483,26 +483,19 @@
 {
     /* Get the path to the executable. */
-    char path [RTPATH_MAX];
-    RTPathAppPrivateArch (path, RTPATH_MAX);
-    size_t sz = strlen (path);
-    path [sz++] = RTPATH_DELIMITER;
-    path [sz] = 0;
+    char path[RTPATH_MAX];
+    RTPathAppPrivateArch(path, RTPATH_MAX);
+    size_t sz = strlen(path);
+    path[sz++] = RTPATH_DELIMITER;
+    path[sz] = 0;
     char *cmd = path + sz;
     sz = RTPATH_MAX - sz;
 
     int rc = 0;
-    RTPROCESS pid = NIL_RTPROCESS;
-    RTENV env = RTENV_DEFAULT;
-
     const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE;
-    Assert (sz >= sizeof (VirtualBox_exe));
-    strcpy (cmd, VirtualBox_exe);
+    Assert(sz >= sizeof(VirtualBox_exe));
+    strcpy(cmd, VirtualBox_exe);
     const char * args[] = {path, 0 };
-# ifdef RT_OS_WINDOWS
-    rc = RTProcCreate (path, args, env, 0, &pid);
-# else
-    rc = RTProcCreate (path, args, env, RTPROC_FLAGS_DAEMONIZE_DEPRECATED, &pid);
-# endif
-    if (RT_FAILURE (rc))
+    rc = RTProcCreate(path, args, RTENV_DEFAULT, RTPROC_FLAGS_DETACHED, NULL);
+    if (RT_FAILURE(rc))
         LogRel(("Systray: Failed to start new selector window! Path=%s, rc=%Rrc\n", path, rc));
 }
@@ -515,13 +508,13 @@
 {
     int rc = 0;
-    QString strTrayWinID = mVBox.GetExtraData (VBoxDefs::GUI_TrayIconWinID);
+    QString strTrayWinID = mVBox.GetExtraData(VBoxDefs::GUI_TrayIconWinID);
     if (false == strTrayWinID.isEmpty())
     {
         /* Check if current tray icon is alive by writing some bogus value. */
-        mVBox.SetExtraData (VBoxDefs::GUI_TrayIconWinID, "0");
+        mVBox.SetExtraData(VBoxDefs::GUI_TrayIconWinID, "0");
         if (mVBox.isOk())
         {
             /* Current tray icon died - clean up. */
-            mVBox.SetExtraData (VBoxDefs::GUI_TrayIconWinID, NULL);
+            mVBox.SetExtraData(VBoxDefs::GUI_TrayIconWinID, NULL);
             strTrayWinID.clear();
         }
@@ -535,26 +528,18 @@
     {
         /* Get the path to the executable. */
-        char path [RTPATH_MAX];
-        RTPathAppPrivateArch (path, RTPATH_MAX);
-        size_t sz = strlen (path);
-        path [sz++] = RTPATH_DELIMITER;
-        path [sz] = 0;
+        char path[RTPATH_MAX];
+        RTPathAppPrivateArch(path, RTPATH_MAX);
+        size_t sz = strlen(path);
+        path[sz++] = RTPATH_DELIMITER;
+        path[sz] = 0;
         char *cmd = path + sz;
         sz = RTPATH_MAX - sz;
 
-        RTPROCESS pid = NIL_RTPROCESS;
-        RTENV env = RTENV_DEFAULT;
-
         const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE;
-        Assert (sz >= sizeof (VirtualBox_exe));
-        strcpy (cmd, VirtualBox_exe);
+        Assert(sz >= sizeof(VirtualBox_exe));
+        strcpy(cmd, VirtualBox_exe);
         const char * args[] = {path, "-systray", 0 };
-# ifdef RT_OS_WINDOWS /** @todo drop this once the RTProcCreate bug has been fixed */
-        rc = RTProcCreate (path, args, env, 0, &pid);
-# else
-        rc = RTProcCreate (path, args, env, RTPROC_FLAGS_DAEMONIZE_DEPRECATED, &pid);
-# endif
-
-        if (RT_FAILURE (rc))
+        rc = RTProcCreate(path, args, RTENV_DEFAULT, RTPROC_FLAGS_DETACHED, NULL);
+        if (RT_FAILURE(rc))
         {
             LogRel(("Systray: Failed to start systray window! Path=%s, rc=%Rrc\n", path, rc));
@@ -566,6 +551,6 @@
     {
         // Use this selector for displaying the tray icon
-        mVBox.SetExtraData (VBoxDefs::GUI_TrayIconWinID,
-                            QString ("%1").arg ((qulonglong) vboxGlobal().mainWindow()->winId()));
+        mVBox.SetExtraData(VBoxDefs::GUI_TrayIconWinID,
+                           QString("%1").arg((qulonglong)vboxGlobal().mainWindow()->winId()));
 
         /* The first process which can grab this "mutex" will win ->
@@ -4935,7 +4920,7 @@
 /**
  * Initialize a debugger config variable.
- * 
+ *
  * @param   piDbgCfgVar         The debugger config variable to init.
- * @param   pszEnvVar           The environment variable name relating to this 
+ * @param   pszEnvVar           The environment variable name relating to this
  *                              variable.
  * @param   pszExtraDataName    The extra data name relating to this variable.
@@ -4964,5 +4949,5 @@
     else if (strEnvValue.isNull() && strExtraValue.isNull())
         *piDbgCfgVar = fDefault ? VBOXGLOBAL_DBG_CFG_VAR_TRUE : VBOXGLOBAL_DBG_CFG_VAR_FALSE;
-    else 
+    else
     {
         QString *pStr = !strEnvValue.isEmpty() ? &strEnvValue : &strExtraValue;
@@ -4980,5 +4965,5 @@
                  || pStr->toLongLong() == 0)
             *piDbgCfgVar = VBOXGLOBAL_DBG_CFG_VAR_FALSE;
-        else 
+        else
         {
             LogFunc(("Ignoring unknown value '%s' for '%s'\n", pStr->toAscii().constData(), pStr == &strEnvValue ? pszEnvVar : pszExtraDataName));
@@ -4988,21 +4973,21 @@
 }
 
-/** 
- * Set a debugger config variable according according to start up argument. 
- *  
- * @param   piDbgCfgVar         The debugger config variable to set. 
- * @param   fState              The value from the command line. 
- */ 
+/**
+ * Set a debugger config variable according according to start up argument.
+ *
+ * @param   piDbgCfgVar         The debugger config variable to set.
+ * @param   fState              The value from the command line.
+ */
 void VBoxGlobal::setDebuggerVar(int *piDbgCfgVar, bool fState)
 {
     if (!(*piDbgCfgVar & VBOXGLOBAL_DBG_CFG_VAR_DONE))
-        *piDbgCfgVar = (fState ? VBOXGLOBAL_DBG_CFG_VAR_TRUE : VBOXGLOBAL_DBG_CFG_VAR_FALSE) 
+        *piDbgCfgVar = (fState ? VBOXGLOBAL_DBG_CFG_VAR_TRUE : VBOXGLOBAL_DBG_CFG_VAR_FALSE)
                      | VBOXGLOBAL_DBG_CFG_VAR_CMD_LINE;
 }
 
 /**
- * Checks the state of a debugger config variable, updating it with the machine 
- * settings on the first invocation. 
- *  
+ * Checks the state of a debugger config variable, updating it with the machine
+ * settings on the first invocation.
+ *
  * @returns true / false.
  * @param   piDbgCfgVar         The debugger config variable to consult.
Index: /trunk/src/VBox/Main/xpcom/server.cpp
===================================================================
--- /trunk/src/VBox/Main/xpcom/server.cpp	(revision 33043)
+++ /trunk/src/VBox/Main/xpcom/server.cpp	(revision 33044)
@@ -1072,4 +1072,6 @@
             /* now we're ready, signal the parent process */
             write(daemon_pipe_wr, "READY", strlen("READY"));
+            /* close writing end of the pipe, its job is done */
+            close(daemon_pipe_wr);
         }
         else
@@ -1150,8 +1152,4 @@
         RTFileDelete(g_pszPidFile);
 
-    /* close writing end of the pipe as well */
-    if (daemon_pipe_wr >= 0)
-        close(daemon_pipe_wr);
-
     return 0;
 }
Index: /trunk/src/VBox/Runtime/r3/posix/process-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/process-posix.cpp	(revision 33043)
+++ /trunk/src/VBox/Runtime/r3/posix/process-posix.cpp	(revision 33044)
@@ -266,5 +266,5 @@
     AssertPtrReturn(pszExec, VERR_INVALID_POINTER);
     AssertReturn(*pszExec, VERR_INVALID_PARAMETER);
-    AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);
+    AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);
     AssertReturn(!(fFlags & RTPROC_FLAGS_DETACHED) || !phProcess, VERR_INVALID_PARAMETER);
     AssertReturn(hEnv != NIL_RTENV, VERR_INVALID_PARAMETER);
@@ -346,20 +346,70 @@
     }
 
-    /*
-     * Spawn the child.
+    pid_t pid = -1;
+
+    /*
+     * Take care of detaching the process.
      *
      * HACK ALERT! Put the process into a new process group with pgid = pid
      * to make sure it differs from that of the parent process to ensure that
-     * the IPRT waipit call doesn't race anyone (read XPCOM) doing group wide
-     * waits.
-     */
-    pid_t pid = -1;
+     * the IPRT waitpid call doesn't race anyone (read XPCOM) doing group wide
+     * waits. setsid() includes the setpgid() functionality.
+     * 2010-10-11 XPCOM no longer waits for anything, but it cannot hurt.
+     */
+#ifndef RT_OS_OS2
+    if (fFlags & RTPROC_FLAGS_DETACHED)
+    {
+# ifdef RT_OS_SOLARIS
+        int templateFd = rtSolarisContractPreFork();
+        if (templateFd == -1)
+            return VERR_OPEN_FAILED;
+# endif /* RT_OS_SOLARIS */
+        pid = fork();
+        if (!pid)
+        {
+# ifdef RT_OS_SOLARIS
+            rtSolarisContractPostForkChild(templateFd);
+# endif /* RT_OS_SOLARIS */
+            setsid(); /* see comment above */
+
+            pid = -1;
+            /* Child falls through to the actual spawn code below. */
+        }
+        else
+        {
+#ifdef RT_OS_SOLARIS
+            rtSolarisContractPostForkParent(templateFd, pid);
+#endif /* RT_OS_SOLARIS */
+            if (pid > 0)
+            {
+                /* Must wait for the temporary process to avoid a zombie. */
+                int status;
+                waitpid(pid, &status, 0);
+                /* Assume that something wasn't found. No detailed info. */
+                if (status)
+                    return VERR_PROCESS_NOT_FOUND;
+                if (phProcess)
+                    *phProcess = 0;
+                return VINF_SUCCESS;
+            }
+            return RTErrConvertFromErrno(errno);
+        }
+    }
+#endif
+
+    /*
+     * Spawn the child.
+     *
+     * Any spawn code MUST not execute any atexit functions if it is for a
+     * detached process. It would lead to running the atexit functions which
+     * make only sense for the parent. libORBit e.g. gets confused by multiple
+     * execution. Remember, there was only a fork() so far, and until exec()
+     * is successfully run there is nothing which would prevent doing anything
+     * silly with the (duplicated) file descriptors.
+     */
 #ifdef HAVE_POSIX_SPAWN
     /** @todo OS/2: implement DETACHED (BACKGROUND stuff), see VbglR3Daemonize.  */
-    /** @todo Try do the detach thing with posix spawn.  */
-    if (   !(fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED))
-        && uid == ~(uid_t)0
-        && gid == ~(gid_t)0
-        )
+    if (   uid == ~(uid_t)0
+        && gid == ~(gid_t)0)
     {
         /* Spawn attributes. */
@@ -428,4 +478,8 @@
             if (!rc)
             {
+                /* For a detached process this happens in the temp process, so
+                 * it's not worth doing anything as this process must exit. */
+                if (fFlags & RTPROC_FLAGS_DETACHED)
+                _Exit(0);
                 if (phProcess)
                     *phProcess = pid;
@@ -433,4 +487,8 @@
             }
         }
+        /* For a detached process this happens in the temp process, so
+         * it's not worth doing anything as this process must exit. */
+        if (fFlags & RTPROC_FLAGS_DETACHED)
+            _Exit(124);
     }
     else
@@ -448,5 +506,6 @@
             rtSolarisContractPostForkChild(templateFd);
 #endif /* RT_OS_SOLARIS */
-            setpgid(0, 0); /* see comment above */
+            if (!(fFlags & RTPROC_FLAGS_DETACHED))
+                setpgid(0, 0); /* see comment above */
 
             /*
@@ -457,5 +516,10 @@
             {
                 if (setgid(gid))
-                    exit(126);
+                {
+                    if (fFlags & RTPROC_FLAGS_DETACHED)
+                        _Exit(126);
+                    else
+                        exit(126);
+                }
             }
 
@@ -463,5 +527,10 @@
             {
                 if (setuid(uid))
-                    exit(126);
+                {
+                    if (fFlags & RTPROC_FLAGS_DETACHED)
+                        _Exit(126);
+                    else
+                        exit(126);
+                }
             }
 #endif
@@ -479,5 +548,10 @@
                     int rc2 = dup2(fd, i);
                     if (rc2 != i)
-                        exit(125);
+                    {
+                        if (fFlags & RTPROC_FLAGS_DETACHED)
+                            _Exit(125);
+                        else
+                            exit(125);
+                    }
                     for (int j = i + 1; j < 3; j++)
                         if (aStdFds[j] == fd)
@@ -492,21 +566,4 @@
 
             /*
-             * Daemonize the process if requested.
-             */
-            if (fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED))
-            {
-                rc = RTProcDaemonizeUsingFork(true /*fNoChDir*/,
-                                              !(fFlags & RTPROC_FLAGS_DAEMONIZE_DEPRECATED) /*fNoClose*/,
-                                              NULL /* pszPidFile */);
-                if (RT_FAILURE(rc))
-                {
-                    /* parent */
-                    AssertReleaseMsgFailed(("RTProcDaemonize returns %Rrc errno=%d\n", rc, errno));
-                    exit(127);
-                }
-                /* daemonized child */
-            }
-
-            /*
              * Finally, execute the requested program.
              */
@@ -520,5 +577,8 @@
                 RTAssertMsg2Weak("execve returns %d errno=%d\n", rc, errno);
             RTAssertReleasePanic();
-            exit(127);
+            if (fFlags & RTPROC_FLAGS_DETACHED)
+                _Exit(127);
+            else
+                exit(127);
         }
 #ifdef RT_OS_SOLARIS
@@ -527,19 +587,18 @@
         if (pid > 0)
         {
+            /* For a detached process this happens in the temp process, so
+             * it's not worth doing anything as this process must exit. */
+            if (fFlags & RTPROC_FLAGS_DETACHED)
+                _Exit(0);
             if (phProcess)
                 *phProcess = pid;
-            else if (fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED))
-            {
-                /* If the process is detached straight away wait for the
-                 * intermediate process to exit (it should do that quickly)
-                 * if the caller didn't want to know the PID. If it wants the
-                 * PID it's his job to wait for it or he gets a zombie. */
-                waitpid(pid, NULL, 0);
-            }
             return VINF_SUCCESS;
         }
-        rc = errno;
-    }
-
+        /* For a detached process this happens in the temp process, so
+         * it's not worth doing anything as this process must exit. */
+        if (fFlags & RTPROC_FLAGS_DETACHED)
+            _Exit(124);
+        return RTErrConvertFromErrno(errno);
+    }
 
     return VERR_NOT_IMPLEMENTED;
Index: /trunk/src/VBox/Runtime/r3/win/process-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/process-win.cpp	(revision 33043)
+++ /trunk/src/VBox/Runtime/r3/win/process-win.cpp	(revision 33044)
@@ -941,5 +941,5 @@
     AssertPtrReturn(pszExec, VERR_INVALID_POINTER);
     AssertReturn(*pszExec, VERR_INVALID_PARAMETER);
-    AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);
+    AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SERVICE)), VERR_INVALID_PARAMETER);
     AssertReturn(!(fFlags & RTPROC_FLAGS_DETACHED) || !phProcess, VERR_INVALID_PARAMETER);
     AssertReturn(hEnv != NIL_RTENV, VERR_INVALID_PARAMETER);
Index: /trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp
===================================================================
--- /trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp	(revision 33043)
+++ /trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp	(revision 33044)
@@ -1216,4 +1216,5 @@
   PRProcessAttr *attr = nsnull;
   nsresult rv = NS_ERROR_FAILURE;
+  PRFileDesc *devNull;
   char *const argv[] = { (char *const) path, nsnull };
   char c;
@@ -1233,9 +1234,19 @@
 
   if (PR_ProcessAttrSetInheritableFD(attr, writable, IPC_STARTUP_PIPE_NAME) != PR_SUCCESS)
+  goto end;
+
+  devNull = PR_Open("/dev/null", PR_RDWR, 0);
+  if (!devNull)
     goto end;
+
+  PR_ProcessAttrSetStdioRedirect(attr, PR_StandardInput, devNull);
+  PR_ProcessAttrSetStdioRedirect(attr, PR_StandardOutput, devNull);
+  PR_ProcessAttrSetStdioRedirect(attr, PR_StandardError, devNull);
 
   if (PR_CreateProcessDetached(path, argv, nsnull, attr) != PR_SUCCESS)
     goto end;
 
+  // Close /dev/null
+  PR_Close(devNull);
   // close the child end of the pipe in order to get notification on unexpected
   // child termination instead of being infinitely blocked in PR_Read().
Index: /trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcdUnix.cpp
===================================================================
--- /trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcdUnix.cpp	(revision 33043)
+++ /trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcdUnix.cpp	(revision 33044)
@@ -50,4 +50,8 @@
 #endif
 
+#ifdef VBOX
+# include <iprt/initterm.h>
+#endif
+
 #include "prio.h"
 #include "prerror.h"
@@ -467,4 +471,9 @@
     PRFileDesc *listenFD = NULL;
     PRNetAddr addr;
+
+#ifdef VBOX
+    /* Set up the runtime without loading the support driver. */
+    RTR3Init();
+#endif
 
     //
@@ -537,4 +546,5 @@
         }
         else {
+#ifndef VBOX
             // redirect all standard file descriptors to /dev/null for
             // proper daemonizing
@@ -545,4 +555,5 @@
             PR_Close(PR_STDERR);
             PR_Open("/dev/null", O_WRONLY, 0);
+#endif
 
             IPC_NotifyParent();
Index: /trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/uxproces.c
===================================================================
--- /trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/uxproces.c	(revision 33043)
+++ /trunk/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/uxproces.c	(revision 33044)
@@ -467,4 +467,8 @@
     const PRProcessAttr *attr)
 {
+#ifdef VBOX
+    /* 2010-10-11 Block this for good. */
+    return NULL;
+#endif
     struct pr_CreateProcOp *op;
     PRProcess *proc;
@@ -529,4 +533,8 @@
     const PRProcessAttr *attr)
 {
+#ifdef VBOX
+    /* 2010-10-11 Block this for good. */
+    return NULL;
+#endif
     if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) {
 	return NULL;
@@ -550,12 +558,6 @@
     RTENV newEnv = RTENV_DEFAULT;
 
-    if (PR_CallOnce(&pr_wp.once, _MD_InitProcesses) == PR_FAILURE) {
-	    return PR_FAILURE;
-    }
     /* this code doesn't support all attributes */
     PR_ASSERT(!attr || !attr->currentDirectory);
-    PR_ASSERT(!attr || !attr->stdinFd);
-    PR_ASSERT(!attr || !attr->stdoutFd);
-    PR_ASSERT(!attr || !attr->stderrFd);
     /* no custom environment, please */
     PR_ASSERT(!envp);
@@ -575,6 +577,29 @@
     }
 
-    vrc = RTProcCreate(path, (const char **)argv, childEnv,
-                       RTPROC_FLAGS_DETACHED, NULL);
+    PRTHANDLE pStdIn = NULL, pStdOut = NULL, pStdErr = NULL;
+    RTHANDLE hStdIn, hStdOut, hStdErr;
+    if (attr && attr->stdinFd)
+    {
+        hStdIn.enmType = RTHANDLETYPE_FILE;
+        RTFileFromNative(&hStdIn.u.hFile, attr->stdinFd->secret->md.osfd);
+        pStdIn = &hStdIn;
+    }
+    if (attr && attr->stdoutFd)
+    {
+        hStdOut.enmType = RTHANDLETYPE_FILE;
+        RTFileFromNative(&hStdOut.u.hFile, attr->stdoutFd->secret->md.osfd);
+        pStdOut = &hStdOut;
+    }
+    if (attr && attr->stderrFd)
+    {
+        hStdErr.enmType = RTHANDLETYPE_FILE;
+        RTFileFromNative(&hStdErr.u.hFile, attr->stderrFd->secret->md.osfd);
+        pStdErr = &hStdErr;
+    }
+
+    vrc = RTProcCreateEx(path, (const char **)argv, childEnv,
+                         RTPROC_FLAGS_DETACHED, pStdIn, pStdOut, pStdErr,
+                         NULL /* pszAsUser */, NULL /* pszPassword */,
+                         NULL /* phProcess */);
     if (newEnv != RTENV_DEFAULT) {
         RTEnvDestroy(newEnv);
@@ -686,5 +711,6 @@
          * to port the NSPR to use IPRT, as currently this races with getting
          * the exit code, but that's pretty harmless. */
-        /** @todo fix this properly, by using IPRT for process management */
+        /* Since 2010-10-11 this code cannot be reached as IPRT took over
+         * what we need, and the rest is blocked. */
         if (_PR_PID_REAPED == pRec->state) {
             DeletePidTable(pRec);
@@ -735,4 +761,6 @@
 	         * to ensure we do not interfere with RT
 	         */
+            /* Since 2010-10-11 this code cannot be reached as IPRT took over
+             * what we need, and the rest is blocked. */
 	        pid = waitpid((pid_t) 0, &status, 0);
 #else
@@ -833,4 +861,6 @@
 	         * to ensure we do not interfere with RT
 	         */
+            /* Since 2010-10-11 this code cannot be reached as IPRT took over
+             * what we need, and the rest is blocked. */
 	        pid = waitpid((pid_t) 0, &status, WNOHANG);
 #else
Index: /trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptio.c
===================================================================
--- /trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptio.c	(revision 33043)
+++ /trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptio.c	(revision 33044)
@@ -336,5 +336,5 @@
          * For sendfile()
          */
-		struct file_spec {		
+		struct file_spec {
         	off_t offset;                       /* offset in file to send */
         	size_t nbytes;                      /* length of file data to send */
@@ -353,5 +353,5 @@
     int nbytes_to_send;                     /* size of header and file */
 #endif  /* HPUX11 */
-    
+
 #ifdef SOLARIS
     /*
@@ -369,5 +369,5 @@
     size_t count;
 #endif  /* LINUX */
- 
+
     PRIntervalTime timeout;                 /* client (relative) timeout */
 
@@ -402,5 +402,5 @@
     LL_I2L(aMil, 1000000);
     LL_DIV(elapsed, elapsed, aMil);
-    
+
     if (NULL != msg) PR_fprintf(debug_out, "%s", msg);
     PR_fprintf(
@@ -444,5 +444,5 @@
 	PRBool wait_for_remaining;
     PRThread *self = PR_GetCurrentThread();
-    
+
 	PR_ASSERT(PR_INTERVAL_NO_WAIT != op->timeout);
 	PR_ASSERT(op->arg1.osfd < FD_SETSIZE);
@@ -491,5 +491,5 @@
 					if ((op->event & POLLOUT) && FD_ISSET(op->arg1.osfd, &wr))
 						revents |= POLLOUT;
-						
+
 					if (op->function(op, revents))
 						op->status = pt_continuation_done;
@@ -548,5 +548,5 @@
 					if ((op->event & POLLOUT) && FD_ISSET(op->arg1.osfd, &wr))
 						revents |= POLLOUT;
-						
+
 					if (op->function(op, revents))
 						op->status = pt_continuation_done;
@@ -587,5 +587,5 @@
 	PRBool wait_for_remaining;
     PRThread *self = PR_GetCurrentThread();
-    
+
 	PR_ASSERT(PR_INTERVAL_NO_WAIT != op->timeout);
 #if defined (_PR_POLL_WITH_SELECT)
@@ -612,5 +612,5 @@
 
 				rv = poll(&tmp_pfd, 1, msecs);
-				
+
 				if (self->state & PT_THREAD_ABORTED)
 				{
@@ -670,5 +670,5 @@
 				}
 				rv = poll(&tmp_pfd, 1, msecs);
-				
+
 				if (self->state & PT_THREAD_ABORTED)
 				{
@@ -686,5 +686,5 @@
 
 					if ((revents & POLLNVAL)  /* busted in all cases */
-						|| ((events & POLLOUT) && (revents & POLLHUP))) 
+						|| ((events & POLLOUT) && (revents & POLLHUP)))
 											/* write op & hup */
 					{
@@ -777,5 +777,5 @@
         op->arg1.osfd, op->arg2.buffer, op->arg3.amount);
     op->syserrno = errno;
-    return ((-1 == op->result.code) && 
+    return ((-1 == op->result.code) &&
             (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno)) ?
         PR_FALSE : PR_TRUE;
@@ -801,5 +801,5 @@
 #endif
     op->syserrno = errno;
-    return ((-1 == op->result.code) && 
+    return ((-1 == op->result.code) &&
             (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno)) ?
         PR_FALSE : PR_TRUE;
@@ -961,5 +961,5 @@
         op->arg4.flags, (struct sockaddr*)op->arg5.addr, &addr_len);
     op->syserrno = errno;
-    return ((-1 == op->result.code) && 
+    return ((-1 == op->result.code) &&
             (EWOULDBLOCK == op->syserrno || EAGAIN == op->syserrno)) ?
         PR_FALSE : PR_TRUE;
@@ -1069,5 +1069,5 @@
 #endif  /* HPUX11 */
 
-#ifdef SOLARIS  
+#ifdef SOLARIS
 static PRBool pt_solaris_sendfile_cont(pt_Continuation *op, PRInt16 revents)
 {
@@ -1089,5 +1089,5 @@
     }
     PR_ASSERT(count <= op->nbytes_to_send);
-    
+
     op->result.code += count;
     if (count < op->nbytes_to_send) {
@@ -1113,5 +1113,5 @@
 #endif  /* SOLARIS */
 
-#ifdef LINUX 
+#ifdef LINUX
 static PRBool pt_linux_sendfile_cont(pt_Continuation *op, PRInt16 revents)
 {
@@ -1152,7 +1152,7 @@
     PR_ASSERT(NULL != _pr_flock_cv);
     _pr_rename_lock = PR_NewLock();
-    PR_ASSERT(NULL != _pr_rename_lock); 
-
-    _PR_InitFdCache();  /* do that */   
+    PR_ASSERT(NULL != _pr_rename_lock);
+
+    _PR_InitFdCache();  /* do that */
 
     _pr_stdin = pt_SetMethods(0, PR_DESC_FILE, PR_FALSE, PR_TRUE);
@@ -1189,9 +1189,9 @@
     _PR_Putfd(_pr_stdout);
     _pr_stdout = NULL;
-    _PR_Putfd(_pr_stderr); 
+    _PR_Putfd(_pr_stderr);
     _pr_stderr = NULL;
 
     _PR_CleanupFdCache();
-    
+
     if (_pr_flock_cv)
     {
@@ -1217,5 +1217,5 @@
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
-    
+
     switch (osfd)
     {
@@ -2126,5 +2126,5 @@
 }
 
-/* 
+/*
  * pt_AIXDispatchSendFile
  */
@@ -2150,8 +2150,8 @@
  *
  *    Send file sfd->fd across socket sd. If specified, header and trailer
- *    buffers are sent before and after the file, respectively. 
+ *    buffers are sent before and after the file, respectively.
  *
  *    PR_TRANSMITFILE_CLOSE_SOCKET flag - close socket after sending file
- *    
+ *
  *    return number of bytes sent or -1 on error
  *
@@ -2160,5 +2160,5 @@
  */
 
-static PRInt32 pt_AIXSendFile(PRFileDesc *sd, PRSendFileData *sfd, 
+static PRInt32 pt_AIXSendFile(PRFileDesc *sd, PRSendFileData *sfd,
 		PRTransmitFileFlags flags, PRIntervalTime timeout)
 {
@@ -2250,5 +2250,5 @@
  *
  *    PR_TRANSMITFILE_CLOSE_SOCKET flag - close socket after sending file
- *    
+ *
  *    return number of bytes sent or -1 on error
  *
@@ -2257,5 +2257,5 @@
  */
 
-static PRInt32 pt_HPUXSendFile(PRFileDesc *sd, PRSendFileData *sfd, 
+static PRInt32 pt_HPUXSendFile(PRFileDesc *sd, PRSendFileData *sfd,
 		PRTransmitFileFlags flags, PRIntervalTime timeout)
 {
@@ -2272,5 +2272,5 @@
             _PR_MD_MAP_FSTAT_ERROR(errno);
             return -1;
-        } 		
+        }
         file_nbytes_to_send = statbuf.st_size - sfd->file_offset;
     } else {
@@ -2363,5 +2363,5 @@
 #endif  /* HPUX11 */
 
-#ifdef SOLARIS 
+#ifdef SOLARIS
 
 /*
@@ -2383,7 +2383,7 @@
 {
     struct stat statbuf;
-    size_t nbytes_to_send, file_nbytes_to_send;	
-    struct sendfilevec sfv_struct[3];  
-    int sfvcnt = 0;	
+    size_t nbytes_to_send, file_nbytes_to_send;
+    struct sendfilevec sfv_struct[3];
+    int sfvcnt = 0;
     size_t xferred;
     PRInt32 count;
@@ -2395,5 +2395,5 @@
             _PR_MD_MAP_FSTAT_ERROR(errno);
             return -1;
-        } 		
+        }
         file_nbytes_to_send = statbuf.st_size - sfd->file_offset;
     } else {
@@ -2406,5 +2406,5 @@
         sfv_struct[sfvcnt].sfv_fd = SFV_FD_SELF;
         sfv_struct[sfvcnt].sfv_flag = 0;
-        sfv_struct[sfvcnt].sfv_off = (off_t) sfd->header; 
+        sfv_struct[sfvcnt].sfv_off = (off_t) sfd->header;
         sfv_struct[sfvcnt].sfv_len = sfd->hlen;
         sfvcnt++;
@@ -2422,5 +2422,5 @@
         sfv_struct[sfvcnt].sfv_fd = SFV_FD_SELF;
         sfv_struct[sfvcnt].sfv_flag = 0;
-        sfv_struct[sfvcnt].sfv_off = (off_t) sfd->trailer; 
+        sfv_struct[sfvcnt].sfv_off = (off_t) sfd->trailer;
         sfv_struct[sfvcnt].sfv_len = sfd->tlen;
         sfvcnt++;
@@ -2431,5 +2431,5 @@
         goto done;
     }
-   	   
+
     /*
      * Strictly speaking, we may have sent some bytes when the
@@ -2498,5 +2498,5 @@
     void *handle;
     PRBool close_it = PR_FALSE;
- 
+
     /*
      * We do not want to unload libsendfile.so.  This handle is leaked
@@ -2521,5 +2521,5 @@
     PR_LOG(_pr_io_lm, PR_LOG_DEBUG,
         ("dlsym(sendfilev) returns %p", pt_solaris_sendfilev_fptr));
-    
+
     if (close_it) {
         dlclose(handle);
@@ -2527,5 +2527,5 @@
 }
 
-/* 
+/*
  * pt_SolarisDispatchSendFile
  */
@@ -2556,5 +2556,5 @@
  *
  *    PR_TRANSMITFILE_CLOSE_SOCKET flag - close socket after sending file
- *    
+ *
  *    return number of bytes sent or -1 on error
  *
@@ -2567,5 +2567,5 @@
 {
     struct stat statbuf;
-    size_t file_nbytes_to_send;	
+    size_t file_nbytes_to_send;
     PRInt32 count = 0;
     ssize_t rv;
@@ -2580,5 +2580,5 @@
             _PR_MD_MAP_FSTAT_ERROR(errno);
             return -1;
-        } 		
+        }
         file_nbytes_to_send = statbuf.st_size - sfd->file_offset;
     } else {
@@ -3075,28 +3075,28 @@
     pt_FileInfo,
     pt_FileInfo64,
-    (PRWritevFN)_PR_InvalidInt,        
-    (PRConnectFN)_PR_InvalidStatus,        
-    (PRAcceptFN)_PR_InvalidDesc,        
-    (PRBindFN)_PR_InvalidStatus,        
-    (PRListenFN)_PR_InvalidStatus,        
-    (PRShutdownFN)_PR_InvalidStatus,    
-    (PRRecvFN)_PR_InvalidInt,        
-    (PRSendFN)_PR_InvalidInt,        
-    (PRRecvfromFN)_PR_InvalidInt,    
-    (PRSendtoFN)_PR_InvalidInt,        
+    (PRWritevFN)_PR_InvalidInt,
+    (PRConnectFN)_PR_InvalidStatus,
+    (PRAcceptFN)_PR_InvalidDesc,
+    (PRBindFN)_PR_InvalidStatus,
+    (PRListenFN)_PR_InvalidStatus,
+    (PRShutdownFN)_PR_InvalidStatus,
+    (PRRecvFN)_PR_InvalidInt,
+    (PRSendFN)_PR_InvalidInt,
+    (PRRecvfromFN)_PR_InvalidInt,
+    (PRSendtoFN)_PR_InvalidInt,
     pt_Poll,
-    (PRAcceptreadFN)_PR_InvalidInt,   
-    (PRTransmitfileFN)_PR_InvalidInt, 
-    (PRGetsocknameFN)_PR_InvalidStatus,    
-    (PRGetpeernameFN)_PR_InvalidStatus,    
-    (PRReservedFN)_PR_InvalidInt,    
-    (PRReservedFN)_PR_InvalidInt,    
+    (PRAcceptreadFN)_PR_InvalidInt,
+    (PRTransmitfileFN)_PR_InvalidInt,
+    (PRGetsocknameFN)_PR_InvalidStatus,
+    (PRGetpeernameFN)_PR_InvalidStatus,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
     (PRGetsocketoptionFN)_PR_InvalidStatus,
     (PRSetsocketoptionFN)_PR_InvalidStatus,
-    (PRSendfileFN)_PR_InvalidInt, 
-    (PRConnectcontinueFN)_PR_InvalidStatus, 
-    (PRReservedFN)_PR_InvalidInt, 
-    (PRReservedFN)_PR_InvalidInt, 
-    (PRReservedFN)_PR_InvalidInt, 
+    (PRSendfileFN)_PR_InvalidInt,
+    (PRConnectcontinueFN)_PR_InvalidStatus,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
     (PRReservedFN)_PR_InvalidInt
 };
@@ -3114,28 +3114,28 @@
     (PRFileInfoFN)_PR_InvalidStatus,
     (PRFileInfo64FN)_PR_InvalidStatus,
-    (PRWritevFN)_PR_InvalidInt,        
-    (PRConnectFN)_PR_InvalidStatus,        
-    (PRAcceptFN)_PR_InvalidDesc,        
-    (PRBindFN)_PR_InvalidStatus,        
-    (PRListenFN)_PR_InvalidStatus,        
-    (PRShutdownFN)_PR_InvalidStatus,    
-    (PRRecvFN)_PR_InvalidInt,        
-    (PRSendFN)_PR_InvalidInt,        
-    (PRRecvfromFN)_PR_InvalidInt,    
-    (PRSendtoFN)_PR_InvalidInt,        
+    (PRWritevFN)_PR_InvalidInt,
+    (PRConnectFN)_PR_InvalidStatus,
+    (PRAcceptFN)_PR_InvalidDesc,
+    (PRBindFN)_PR_InvalidStatus,
+    (PRListenFN)_PR_InvalidStatus,
+    (PRShutdownFN)_PR_InvalidStatus,
+    (PRRecvFN)_PR_InvalidInt,
+    (PRSendFN)_PR_InvalidInt,
+    (PRRecvfromFN)_PR_InvalidInt,
+    (PRSendtoFN)_PR_InvalidInt,
     pt_Poll,
-    (PRAcceptreadFN)_PR_InvalidInt,   
-    (PRTransmitfileFN)_PR_InvalidInt, 
-    (PRGetsocknameFN)_PR_InvalidStatus,    
-    (PRGetpeernameFN)_PR_InvalidStatus,    
-    (PRReservedFN)_PR_InvalidInt,    
-    (PRReservedFN)_PR_InvalidInt,    
+    (PRAcceptreadFN)_PR_InvalidInt,
+    (PRTransmitfileFN)_PR_InvalidInt,
+    (PRGetsocknameFN)_PR_InvalidStatus,
+    (PRGetpeernameFN)_PR_InvalidStatus,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
     (PRGetsocketoptionFN)_PR_InvalidStatus,
     (PRSetsocketoptionFN)_PR_InvalidStatus,
-    (PRSendfileFN)_PR_InvalidInt, 
-    (PRConnectcontinueFN)_PR_InvalidStatus, 
-    (PRReservedFN)_PR_InvalidInt, 
-    (PRReservedFN)_PR_InvalidInt, 
-    (PRReservedFN)_PR_InvalidInt, 
+    (PRSendfileFN)_PR_InvalidInt,
+    (PRConnectcontinueFN)_PR_InvalidStatus,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
     (PRReservedFN)_PR_InvalidInt
 };
@@ -3172,9 +3172,9 @@
     pt_GetSocketOption,
     pt_SetSocketOption,
-    pt_SendFile, 
+    pt_SendFile,
     pt_ConnectContinue,
-    (PRReservedFN)_PR_InvalidInt, 
-    (PRReservedFN)_PR_InvalidInt, 
-    (PRReservedFN)_PR_InvalidInt, 
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
     (PRReservedFN)_PR_InvalidInt
 };
@@ -3211,9 +3211,9 @@
     pt_GetSocketOption,
     pt_SetSocketOption,
-    (PRSendfileFN)_PR_InvalidInt, 
-    (PRConnectcontinueFN)_PR_InvalidStatus, 
-    (PRReservedFN)_PR_InvalidInt, 
-    (PRReservedFN)_PR_InvalidInt, 
-    (PRReservedFN)_PR_InvalidInt, 
+    (PRSendfileFN)_PR_InvalidInt,
+    (PRConnectcontinueFN)_PR_InvalidStatus,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
     (PRReservedFN)_PR_InvalidInt
 };
@@ -3231,28 +3231,28 @@
     (PRFileInfoFN)_PR_InvalidStatus,
     (PRFileInfo64FN)_PR_InvalidStatus,
-    (PRWritevFN)_PR_InvalidInt,        
-    (PRConnectFN)_PR_InvalidStatus,        
-    (PRAcceptFN)_PR_InvalidDesc,        
-    (PRBindFN)_PR_InvalidStatus,        
-    (PRListenFN)_PR_InvalidStatus,        
-    (PRShutdownFN)_PR_InvalidStatus,    
-    (PRRecvFN)_PR_InvalidInt,        
-    (PRSendFN)_PR_InvalidInt,        
-    (PRRecvfromFN)_PR_InvalidInt,    
-    (PRSendtoFN)_PR_InvalidInt,        
+    (PRWritevFN)_PR_InvalidInt,
+    (PRConnectFN)_PR_InvalidStatus,
+    (PRAcceptFN)_PR_InvalidDesc,
+    (PRBindFN)_PR_InvalidStatus,
+    (PRListenFN)_PR_InvalidStatus,
+    (PRShutdownFN)_PR_InvalidStatus,
+    (PRRecvFN)_PR_InvalidInt,
+    (PRSendFN)_PR_InvalidInt,
+    (PRRecvfromFN)_PR_InvalidInt,
+    (PRSendtoFN)_PR_InvalidInt,
 	pt_Poll,
-    (PRAcceptreadFN)_PR_InvalidInt,   
-    (PRTransmitfileFN)_PR_InvalidInt, 
-    (PRGetsocknameFN)_PR_InvalidStatus,    
-    (PRGetpeernameFN)_PR_InvalidStatus,    
-    (PRReservedFN)_PR_InvalidInt,    
-    (PRReservedFN)_PR_InvalidInt,    
+    (PRAcceptreadFN)_PR_InvalidInt,
+    (PRTransmitfileFN)_PR_InvalidInt,
+    (PRGetsocknameFN)_PR_InvalidStatus,
+    (PRGetpeernameFN)_PR_InvalidStatus,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
     (PRGetsocketoptionFN)_PR_InvalidStatus,
     (PRSetsocketoptionFN)_PR_InvalidStatus,
-    (PRSendfileFN)_PR_InvalidInt, 
-    (PRConnectcontinueFN)_PR_InvalidStatus, 
-    (PRReservedFN)_PR_InvalidInt, 
-    (PRReservedFN)_PR_InvalidInt, 
-    (PRReservedFN)_PR_InvalidInt, 
+    (PRSendfileFN)_PR_InvalidInt,
+    (PRConnectcontinueFN)_PR_InvalidStatus,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
+    (PRReservedFN)_PR_InvalidInt,
     (PRReservedFN)_PR_InvalidInt
 };
@@ -3306,5 +3306,5 @@
 {
     PRFileDesc *fd = _PR_Getfd();
-    
+
     if (fd == NULL) PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
     else
@@ -3316,10 +3316,7 @@
         {
             /* By default, a Unix fd is not closed on exec. */
-#ifdef DEBUG
             PRIntn flags;
             flags = fcntl(osfd, F_GETFD, 0);
-            PR_ASSERT(0 == flags);
-#endif
-            fd->secret->inheritable = _PR_TRI_TRUE;
+            fd->secret->inheritable = flags & FD_CLOEXEC ? _PR_TRI_FALSE : _PR_TRI_TRUE;
         }
         switch (type)
@@ -3395,5 +3392,5 @@
     fd->secret->inheritable = _PR_TRI_UNKNOWN;
     return fd;
-    
+
 failed:
     PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
@@ -3464,10 +3461,10 @@
 #if defined(_PR_INET6_PROBE)
 	if (PR_AF_INET6 == domain) {
-		if (_pr_ipv6_is_present == PR_FALSE) 
+		if (_pr_ipv6_is_present == PR_FALSE)
 			domain = AF_INET;
 		else
 			domain = AF_INET6;
 	}
-#elif defined(_PR_INET6) 
+#elif defined(_PR_INET6)
 	if (PR_AF_INET6 == domain)
 		domain = AF_INET6;
@@ -3498,5 +3495,5 @@
 	if (fd != NULL) {
 		/*
-		 * For platforms with no support for IPv6 
+		 * For platforms with no support for IPv6
 		 * create layered socket for IPv4-mapped IPv6 addresses
 		 */
@@ -3614,5 +3611,5 @@
     pt_MapError(_PR_MD_MAP_ACCESS_ERROR, errno);
     return PR_FAILURE;
-    
+
 }  /* PR_Access */
 
@@ -3642,5 +3639,5 @@
     ** a new file at the same time. And we have to hold that lock while we
     ** test to see if the file exists and do the rename. The other place
-    ** where the lock is held is in PR_Open() when possibly creating a 
+    ** where the lock is held is in PR_Open() when possibly creating a
     ** new file.
     */
@@ -4250,5 +4247,5 @@
 						}
 					}
-                } else 
+                } else
                     _PR_MD_MAP_SELECT_ERROR(oserror);
             }
@@ -4399,4 +4396,6 @@
         return PR_FAILURE;
     }
+    fcntl(pipefd[0], F_SETFD, FD_CLOEXEC);
+    fcntl(pipefd[1], F_SETFD, FD_CLOEXEC);
     *readPipe = pt_SetMethods(pipefd[0], PR_DESC_PIPE, PR_FALSE, PR_FALSE);
     if (NULL == *readPipe)
@@ -4562,5 +4561,5 @@
     }
     PR_Unlock(_pr_flock_lock);
- 
+
     return status;
 }  /* PR_LockFile */
@@ -4580,5 +4579,5 @@
     else fd->secret->lockCount += 1;
     PR_Unlock(_pr_flock_lock);
- 
+
     return status;
 }  /* PR_TLockFile */
@@ -4616,5 +4615,5 @@
     struct rlimit rlim;
 
-    if ( getrlimit(RLIMIT_NOFILE, &rlim) < 0) 
+    if ( getrlimit(RLIMIT_NOFILE, &rlim) < 0)
        return -1;
 
@@ -4644,5 +4643,5 @@
         rlim.rlim_cur = table_size;
 
-    if ( setrlimit(RLIMIT_NOFILE, &rlim) < 0) 
+    if ( setrlimit(RLIMIT_NOFILE, &rlim) < 0)
         return -1;
 
@@ -4771,5 +4770,5 @@
     if (!pr_set)
         return 0;
-   
+
     FD_ZERO(set);
 
@@ -4813,5 +4812,5 @@
 
 PR_IMPLEMENT(PRInt32) PR_Select(
-    PRInt32 unused, PR_fd_set *pr_rd, PR_fd_set *pr_wr, 
+    PRInt32 unused, PR_fd_set *pr_rd, PR_fd_set *pr_wr,
     PR_fd_set *pr_ex, PRIntervalTime timeout)
 {
@@ -4880,5 +4879,5 @@
 #endif /* defined(_PR_PTHREADS) */
 
-#ifdef MOZ_UNICODE 
+#ifdef MOZ_UNICODE
 /* ================ UTF16 Interfaces ================================ */
 PR_IMPLEMENT(PRFileDesc*) PR_OpenFileUTF16(
Index: /trunk/src/libs/xpcom18a4/xpcom/threads/plevent.c
===================================================================
--- /trunk/src/libs/xpcom18a4/xpcom/threads/plevent.c	(revision 33043)
+++ /trunk/src/libs/xpcom18a4/xpcom/threads/plevent.c	(revision 33044)
@@ -863,4 +863,8 @@
         return PR_FAILURE;
     }
+#ifdef VBOX
+    fcntl(self->eventPipe[0], F_SETFD, FD_CLOEXEC);
+    fcntl(self->eventPipe[1], F_SETFD, FD_CLOEXEC);
+#endif
 
     /* make the pipe nonblocking */
