Index: /trunk/src/VBox/Additions/x11/VBoxClient/main.cpp
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/main.cpp	(revision 52576)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/main.cpp	(revision 52577)
@@ -72,5 +72,5 @@
             system(pszCommand);
     }
-    exit(1);
+    _exit(1);
 }
 
@@ -84,8 +84,5 @@
     int rc = RTCritSectEnter(&g_critSect);
     if (RT_FAILURE(rc))
-    {
-        LogRel(("VBoxClient: Failure while acquiring the global critical section, rc=%Rrc\n", rc));
-        abort();
-    }
+        VBClFatalError(("VBoxClient: Failure while acquiring the global critical section, rc=%Rrc\n", rc));
     if (g_pService)
         (*g_pService)->cleanup(g_pService);
@@ -99,5 +96,5 @@
  * A standard signal handler which cleans up and exits.
  */
-void vboxClientSignalHandler(int cSignal)
+static void vboxClientSignalHandler(int cSignal)
 {
     LogRel(("VBoxClient: terminated with signal %d\n", cSignal));
@@ -110,5 +107,5 @@
  * Xlib error handler for certain errors that we can't avoid.
  */
-int vboxClientXLibErrorHandler(Display *pDisplay, XErrorEvent *pError)
+static int vboxClientXLibErrorHandler(Display *pDisplay, XErrorEvent *pError)
 {
     char errorText[1024];
@@ -134,5 +131,5 @@
  * cleans up and exits.
  */
-void vboxClientSetSignalHandlers(void)
+static void vboxClientSetSignalHandlers(void)
 {
     struct sigaction sigAction;
@@ -361,5 +358,5 @@
      * object should probably never be used from multiple threads anyway. */
     if (!XInitThreads())
-        return 1;
+        VBClFatalError(("Failed to initialize X11 threads\n"));
     /* Get our file name for error output. */
     pcszFileName = RTPathFilename(argv[0]);
@@ -369,9 +366,6 @@
     rc = VbglR3InitUser();
     if (RT_FAILURE(rc))
-    {
-        RTPrintf("%s: failed to connect to the VirtualBox kernel service, rc=%Rrc\n",
-                 pcszFileName, rc);
-        return 1;
-    }
+        VBClFatalError(("%s: failed to connect to the VirtualBox kernel service, rc=%Rrc\n",
+                 pcszFileName, rc));
 
     /* Parse our option(s) */
@@ -444,53 +438,39 @@
     }
 
-    do {
-        pcszStage = "Initialising critical section";
-        rc = RTCritSectInit(&g_critSect);
-        if (RT_FAILURE(rc))
-            break;
-        pcszStage = "Getting home directory for pid-file";
-        rc = RTPathUserHome(g_szPidFile, sizeof(g_szPidFile));
-        if (RT_FAILURE(rc))
-            break;
-        pcszStage = "Creating pid-file path";
-        rc = RTPathAppend(g_szPidFile, sizeof(g_szPidFile),
-                          (*g_pService)->getPidFilePath());
-        if (RT_FAILURE(rc))
-            break;
-        pcszStage = "Daemonising";
-        if (fDaemonise)
-            rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */);
-        if (RT_FAILURE(rc))
-            break;
-        pcszStage = "Creating pid-file";
-        if (g_szPidFile[0])
-            rc = VbglR3PidFile(g_szPidFile, &g_hPidFile);
-        if (RT_FAILURE(rc))
-            break;
-        /* Set signal handlers to clean up on exit. */
-        vboxClientSetSignalHandlers();
-        /* Set an X11 error handler, so that we don't die when we get unavoidable
-         * errors. */
-        XSetErrorHandler(vboxClientXLibErrorHandler);
-        /* Set an X11 I/O error handler, so that we can shutdown properly on
-         * fatal errors. */
-        XSetIOErrorHandler(vboxClientXLibIOErrorHandler);
-        pcszStage = "Initialising service";
-        rc = (*g_pService)->init(g_pService);
-    } while (0);
-    if (RT_FAILURE(rc))
-    {
-        LogRelFunc(("VBoxClient: failed at stage: \"%s\" rc: %Rrc\n",
-                    pcszStage, rc));
-        VbglR3Term();
-        return 1;
-    }
-
+    rc = RTCritSectInit(&g_critSect);
+    if (RT_FAILURE(rc))
+        VBClFatalError(("Initialising critical section: %Rrc\n", rc));
+    if (RT_FAILURE(rc))
+        VBClFatalError(("Initialising critical section: %Rrc\n", rc));
+    rc = RTPathUserHome(g_szPidFile, sizeof(g_szPidFile));
+    if (RT_FAILURE(rc))
+        VBClFatalError(("Getting home directory for pid-file: %Rrc\n", rc));
+    rc = RTPathAppend(g_szPidFile, sizeof(g_szPidFile),
+                      (*g_pService)->getPidFilePath());
+    if (RT_FAILURE(rc))
+        VBClFatalError(("Creating pid-file path: %Rrc\n", rc));
+    if (fDaemonise)
+        rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */);
+    if (RT_FAILURE(rc))
+        VBClFatalError(("Daemonizing: %Rrc\n", rc));
+    if (g_szPidFile[0])
+        rc = VbglR3PidFile(g_szPidFile, &g_hPidFile);
+    if (RT_FAILURE(rc))
+        VBClFatalError(("Creating pid-file: %Rrc\n", rc));
+    /* Set signal handlers to clean up on exit. */
+    vboxClientSetSignalHandlers();
+    /* Set an X11 error handler, so that we don't die when we get unavoidable
+     * errors. */
+    XSetErrorHandler(vboxClientXLibErrorHandler);
+    /* Set an X11 I/O error handler, so that we can shutdown properly on
+     * fatal errors. */
+    XSetIOErrorHandler(vboxClientXLibIOErrorHandler);
+    rc = (*g_pService)->init(g_pService);
+    if (RT_FAILURE(rc))
+        VBClFatalError(("Initialising service: %Rrc\n", rc));
     rc = startMonitorThread();
     if (RT_FAILURE(rc))
-        LogRel(("Failed to start the monitor thread (%Rrc).  Exiting.\n",
-                 rc));
-    else
-        (*g_pService)->run(g_pService, fDaemonise);  /* Should never return. */
+        VBClFatalError(("Starting monitor thread: %Rrc\n", rc));
+    (*g_pService)->run(g_pService, fDaemonise);  /* Should never return. */
     VBClCleanUp();
     return 1;
