Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp	(revision 40681)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp	(revision 40682)
@@ -234,6 +234,6 @@
     {
         VBoxServiceVerbose(3, "Waiting for host msg ...\n");
-        uint32_t uMsg;
-        uint32_t cParms;
+        uint32_t uMsg = 0;
+        uint32_t cParms = 0;
         rc = VbglR3GuestCtrlWaitForHostMsg(g_uControlSvcClientID, &uMsg, &cParms);
         if (rc == VERR_TOO_MUCH_DATA)
@@ -356,5 +356,9 @@
         VBoxServiceError("Starting process failed with rc=%Rrc\n", rc);
 
-        int rc2 = VbglR3GuestCtrlExecReportStatus(uClientID, uContextID, 0 /* PID, invalid. */,
+        /*
+         * Note: The context ID can be 0 because we mabye weren't able to fetch the command
+         *       from the host. The host in case has to deal with that!
+         */
+        int rc2 = VbglR3GuestCtrlExecReportStatus(uClientID, uContextID /* Might be 0 */, 0 /* PID, invalid */,
                                                   PROC_STS_ERROR, rc,
                                                   NULL /* pvData */, 0 /* cbData */);
@@ -591,9 +595,6 @@
         if (RT_SUCCESS(rc))
         {
-            if (cbWritten || !cbSize) /* Did we write something or was there anything to write at all? */
-            {
-                uStatus = INPUT_STS_WRITTEN;
-                uFlags = 0;
-            }
+            uStatus = INPUT_STS_WRITTEN;
+            uFlags = 0; /* No flags at the moment. */
         }
         else
@@ -752,6 +753,6 @@
             PVBOXSERVICECTRLTHREAD pNext = RTListNodeGetNext(&pThread->Node, VBOXSERVICECTRLTHREAD, Node);
             bool fLast = RTListNodeIsLast(&g_lstControlThreadsInactive, &pThread->Node);
-
-            int rc2 = VBoxServiceControlThreadWait(pThread, 30 * 1000 /* 30 seconds max. */);
+            int rc2 = VBoxServiceControlThreadWait(pThread, 30 * 1000 /* 30 seconds max. */,
+                                                   NULL /* rc */);
             if (RT_SUCCESS(rc2))
             {
@@ -761,5 +762,5 @@
                 if (RT_FAILURE(rc2))
                 {
-                    VBoxServiceError("Stopping guest process thread failed with rc=%Rrc\n", rc2);
+                    VBoxServiceError("Freeing guest process thread failed with rc=%Rrc\n", rc2);
                     if (RT_SUCCESS(rc)) /* Keep original failure. */
                         rc = rc2;
@@ -806,5 +807,6 @@
 
         int rc2 = VBoxServiceControlThreadWait(pThread,
-                                               30 * 1000 /* Wait 30 seconds max. */);
+                                               30 * 1000 /* Wait 30 seconds max. */,
+                                               NULL /* rc */);
         if (RT_FAILURE(rc2))
             VBoxServiceError("Guest process thread failed to stop; rc=%Rrc\n", rc2);
Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlThread.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlThread.cpp	(revision 40681)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlThread.cpp	(revision 40682)
@@ -236,15 +236,18 @@
  * @param   pThread             Thread to wait shutting down for.
  * @param   RTMSINTERVAL        Timeout in ms to wait for shutdown.
+ * @param   prc                 Where to store the thread's return code. Optional.
  */
 int VBoxServiceControlThreadWait(const PVBOXSERVICECTRLTHREAD pThread,
-                                 RTMSINTERVAL msTimeout)
+                                 RTMSINTERVAL msTimeout, int *prc)
 {
     AssertPtrReturn(pThread, VERR_INVALID_POINTER);
+    /* prc is optional. */
+
     int rc = VINF_SUCCESS;
     if (   pThread->Thread != NIL_RTTHREAD
         && ASMAtomicReadBool(&pThread->fStarted))
     {
-        VBoxServiceVerbose(2, "[PID %u]: Waiting for shutdown ...\n",
-                           pThread->uPID);
+        VBoxServiceVerbose(2, "[PID %u]: Waiting for shutdown of pThread=0x%p = \"%s\"...\n",
+                           pThread->uPID, pThread, pThread->pszCmd);
 
         /* Wait a bit ... */
@@ -258,10 +261,8 @@
         else
         {
-            if (RT_FAILURE(rcThread))
-            {
-                VBoxServiceError("[PID %u]: Shutdown returned error rc=%Rrc\n",
-                                 pThread->uPID, rcThread);
-                rc = rcThread;
-            }
+            VBoxServiceVerbose(3, "[PID %u]: Thread reported exit code=%Rrc\n",
+                               pThread->uPID, rcThread);
+            if (prc)
+                *prc = rcThread;
         }
     }
@@ -1379,5 +1380,6 @@
 {
     AssertPtrReturn(pThread, VERR_INVALID_POINTER);
-    VBoxServiceVerbose(3, "Thread of process \"%s\" started\n", pThread->pszCmd);
+    VBoxServiceVerbose(3, "Thread of process pThread=0x%p = \"%s\" started\n",
+                       pThread, pThread->pszCmd);
 
     int rc = VBoxServiceControlListSet(VBOXSERVICECTRLTHREADLIST_RUNNING, pThread);
Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h	(revision 40681)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h	(revision 40682)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2007-2011 Oracle Corporation
+ * Copyright (C) 2007-2012 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -397,5 +397,6 @@
 extern int                      VBoxServiceControlThreadPerform(uint32_t uPID, PVBOXSERVICECTRLREQUEST pRequest);
 extern int                      VBoxServiceControlThreadStop(const PVBOXSERVICECTRLTHREAD pThread);
-extern int                      VBoxServiceControlThreadWait(const PVBOXSERVICECTRLTHREAD pThread, RTMSINTERVAL msTimeout);
+extern int                      VBoxServiceControlThreadWait(const PVBOXSERVICECTRLTHREAD pThread,
+                                                             RTMSINTERVAL msTimeout, int *prc);
 extern int                      VBoxServiceControlThreadFree(PVBOXSERVICECTRLTHREAD pThread);
 /* Request handling. */
Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp	(revision 40681)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp	(revision 40682)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2011 Oracle Corporation
+ * Copyright (C) 2012 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
