summaryrefslogtreecommitdiff
path: root/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
diff options
context:
space:
mode:
authorFelix Geyer <debfx-pkg@fobos.de>2011-07-29 17:55:18 +0200
committerFelix Geyer <debfx-pkg@fobos.de>2011-07-29 17:55:18 +0200
commitcba113ca2826bc4814be2f69a7704c865a37d4ea (patch)
tree511123b10dd1e58e56958520534f5c50e6f570fc /src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
parent6a16f6900dd884e07125b51c9625f6be0a1f9b70 (diff)
downloadvirtualbox-cba113ca2826bc4814be2f69a7704c865a37d4ea.tar.gz
Imported Upstream version 4.1.0-dfsgupstream/4.1.0-dfsg
Diffstat (limited to 'src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp')
-rw-r--r--src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp b/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
index 0e5155ef5..8be9dafe0 100644
--- a/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
+++ b/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
@@ -1,4 +1,4 @@
-/* $Id: VBoxServiceControlExec.cpp $ */
+/* $Id: VBoxServiceControlExec.cpp 37816 2011-07-07 11:52:16Z vboxsync $ */
/** @file
* VBoxServiceControlExec - Utility functions for process execution.
*/
@@ -190,24 +190,24 @@ static int VBoxServiceControlExecProcHandleStdInWritableEvent(RTPOLLSET hPollSe
/**
- * Handle pending output data or error on standard out, standard error or the
- * test pipe.
+ * Handle pending output data/error on standard out or standard error.
*
- * @returns IPRT status code from client send.
- * @param pThread The thread specific data.
+ * @return IPRT status code.
* @param hPollSet The polling set.
* @param fPollEvt The event mask returned by RTPollNoResume.
- * @param phPipeR The pipe handle.
- * @param pu32Crc The current CRC-32 of the stream. (In/Out)
- * @param uHandleId The handle ID.
- *
- * @todo Put the last 4 parameters into a struct!
+ * @param phPipeR The pipe to be read from.
+ * @param uHandleId Handle ID of the pipe to be read from.
+ * @param pBuf Pointer to pipe buffer to store the read data into.
*/
static int VBoxServiceControlExecProcHandleOutputEvent(RTPOLLSET hPollSet, uint32_t fPollEvt, PRTPIPE phPipeR,
- uint32_t uHandleId, PVBOXSERVICECTRLEXECPIPEBUF pStdOutBuf)
+ uint32_t uHandleId, PVBOXSERVICECTRLEXECPIPEBUF pBuf)
{
+ AssertPtrReturn(phPipeR, VERR_INVALID_POINTER);
+ AssertPtrReturn(pBuf, VERR_INVALID_POINTER);
+
#ifdef DEBUG
- VBoxServiceVerbose(4, "ControlExec: HandleOutputEvent: fPollEvt=%#x\n", fPollEvt);
+ VBoxServiceVerbose(4, "ControlExec: HandleOutputEvent: fPollEvt=%#x, uHandle=%u\n",
+ fPollEvt, uHandleId);
#endif
/*
@@ -221,7 +221,7 @@ static int VBoxServiceControlExecProcHandleOutputEvent(RTPOLLSET hPollSet, uint3
if (RT_SUCCESS(rc2) && cbRead)
{
uint32_t cbWritten;
- rc = VBoxServicePipeBufWriteToBuf(pStdOutBuf, abBuf,
+ rc = VBoxServicePipeBufWriteToBuf(pBuf, abBuf,
cbRead, false /* Pending close */, &cbWritten);
if (RT_SUCCESS(rc))
{
@@ -375,7 +375,7 @@ static int VBoxServiceControlExecProcLoop(PVBOXSERVICECTRLTHREAD pThread,
case VBOXSERVICECTRLPIPEID_STDERR:
rc = VBoxServiceControlExecProcHandleOutputEvent(hPollSet, fPollEvt, phStdErrR,
- VBOXSERVICECTRLPIPEID_STDERR, &pData->stdOut);
+ VBOXSERVICECTRLPIPEID_STDERR, &pData->stdErr);
break;
default:
@@ -579,18 +579,22 @@ static int VBoxServiceControlExecProcLoop(PVBOXSERVICECTRLTHREAD pThread,
*/
if (g_cVerbosity >= 5)
{
+ VBoxServiceVerbose(5, "StdOut of process (PID %u):\n", pData->uPID);
+
uint8_t szBuf[_64K];
uint32_t cbOffset = 0;
uint32_t cbRead, cbLeft;
- while (RT_SUCCESS( VBoxServicePipeBufPeek(&pData->stdOut, szBuf, sizeof(szBuf),
+ while ( RT_SUCCESS(VBoxServicePipeBufPeek(&pData->stdOut, szBuf, sizeof(szBuf),
cbOffset, &cbRead, &cbLeft))
- && cbRead)
+ && cbRead)
{
- VBoxServiceVerbose(5, "[%u]: %s\n", pData->uPID, szBuf);
+ RTStrmWrite(g_pStdOut, szBuf, cbRead);
cbOffset += cbRead;
if (!cbLeft)
break;
}
+
+ VBoxServiceVerbose(5, "\n");
}
}
else
@@ -1350,7 +1354,7 @@ int VBoxServiceControlExecHandleCmdGetOutput(uint32_t u32ClientId, uint32_t uNum
* regardless whether we got data or not! Otherwise the progress object
* on the host never will get completed! */
/* cbRead now contains actual size. */
- rc = VbglR3GuestCtrlExecSendOut(u32ClientId, uContextID, uPID, uHandleID, 0 /* Flags */,
+ rc = VbglR3GuestCtrlExecSendOut(u32ClientId, uContextID, uPID, uHandleID, uFlags,
pBuf, cbRead);
}
RTMemFree(pBuf);