Index: /trunk/src/VBox/Additions/x11/VBoxClient/main.cpp
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/main.cpp	(revision 35616)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/main.cpp	(revision 35617)
@@ -239,4 +239,34 @@
         exit(1);
     }
+    /* Get the path for the pidfiles */
+    rc = RTPathUserHome(g_szPidFile, sizeof(g_szPidFile));
+    if (RT_FAILURE(rc))
+    {
+        RTPrintf("VBoxClient: failed to get home directory, rc=%Rrc.  Exiting.\n", rc);
+        LogRel(("VBoxClient: failed to get home directory, rc=%Rrc.  Exiting.\n", rc));
+        return 1;
+    }
+    rc = RTPathAppend(g_szPidFile, sizeof(g_szPidFile), g_pService->getPidFilePath());
+    if (RT_FAILURE(rc))
+    {
+        RTPrintf("VBoxClient: RTPathAppend failed with rc=%Rrc.  Exiting.\n", rc);
+        LogRel(("VBoxClient: RTPathAppend failed with rc=%Rrc.  Exiting.\n", rc));
+        return 1;
+    }
+
+    /* Initialise the guest library. */
+    if (RT_FAILURE(VbglR3InitUser()))
+    {
+        RTPrintf("Failed to connect to the VirtualBox kernel service\n");
+        LogRel(("Failed to connect to the VirtualBox kernel service\n"));
+        return 1;
+    }
+    if (g_szPidFile[0] && RT_FAILURE(VbglR3PidFile(g_szPidFile, &g_hPidFile)))
+    {
+        RTPrintf("Failed to create a pidfile.  Exiting.\n");
+        LogRel(("Failed to create a pidfile.  Exiting.\n"));
+        VbglR3Term();
+        return 1;
+    }
     if (fDaemonise)
     {
@@ -251,35 +281,4 @@
             return 1;
         }
-    }
-    /** @todo explain why we aren't using RTPathUserHome here so it doesn't get
-     *        changed accidentally during some cleanup effort. */
-    rc = RTEnvGetEx(RTENV_DEFAULT, "HOME", g_szPidFile, sizeof(g_szPidFile), NULL);
-    if (RT_FAILURE(rc))
-    {
-        RTPrintf("VBoxClient: failed to get home directory, rc=%Rrc.  Exiting.\n", rc);
-        LogRel(("VBoxClient: failed to get home directory, rc=%Rrc.  Exiting.\n", rc));
-        return 1;
-    }
-    rc = RTPathAppend(g_szPidFile, sizeof(g_szPidFile), g_pService->getPidFilePath());
-    if (RT_FAILURE(rc))
-    {
-        RTPrintf("VBoxClient: RTPathAppend failed with rc=%Rrc.  Exiting.\n", rc);
-        LogRel(("VBoxClient: RTPathAppend failed with rc=%Rrc.  Exiting.\n", rc));
-        return 1;
-    }
-
-    /* Initialise the guest library. */
-    if (RT_FAILURE(VbglR3InitUser()))
-    {
-        RTPrintf("Failed to connect to the VirtualBox kernel service\n");
-        LogRel(("Failed to connect to the VirtualBox kernel service\n"));
-        return 1;
-    }
-    if (g_szPidFile[0] && RT_FAILURE(VbglR3PidFile(g_szPidFile, &g_hPidFile)))
-    {
-        RTPrintf("Failed to create a pidfile.  Exiting.\n");
-        LogRel(("Failed to create a pidfile.  Exiting.\n"));
-        VbglR3Term();
-        return 1;
     }
     /* Set signal handlers to clean up on exit. */
