GuestProcessImpl.h revision 81096b0da0061583a511da27088643aa949a1ec9
/* $Id$ */
/** @file
* VirtualBox Main - Guest process handling.
*/
/*
* Copyright (C) 2012-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ____H_GUESTPROCESSIMPL
#define ____H_GUESTPROCESSIMPL
#include "VirtualBoxBase.h"
#include "GuestCtrlImplPrivate.h"
/**
* Class for handling a guest process.
*/
{
* @{ */
int init(Console *aConsole, GuestSession *aSession, ULONG aProcessID, const GuestProcessStartupInfo &aProcInfo);
void uninit(void);
HRESULT FinalConstruct(void);
void FinalRelease(void);
/** @} */
/** @name IProcess interface.
* @{ */
STDMETHOD(WaitForArray)(ComSafeArrayIn(ProcessWaitForFlag_T, aFlags), ULONG aTimeoutMS, ProcessWaitResult_T *aReason);
STDMETHOD(Write)(ULONG aHandle, ULONG aFlags, ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten);
STDMETHOD(WriteArray)(ULONG aHandle, ComSafeArrayIn(ProcessInputFlag_T, aFlags), ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten);
/** @} */
/** @name Public internal methods.
* @{ */
int readData(uint32_t uHandle, uint32_t uSize, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbRead, int *pGuestRc);
int startProcessAsync(void);
static ProcessWaitResult_T waitFlagsToResultEx(uint32_t fWaitFlags, ProcessStatus_T procStatus, uint32_t uProcFlags, uint32_t uProtocol);
int waitForInputNotify(GuestWaitEvent *pEvent, uint32_t uHandle, uint32_t uTimeoutMS, ProcessInputStatus_T *pInputStatus, uint32_t *pcbProcessed);
int waitForOutput(GuestWaitEvent *pEvent, uint32_t uHandle, uint32_t uTimeoutMS, void* pvData, size_t cbData, uint32_t *pcbRead);
int waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, ProcessStatus_T *pProcessStatus, int *pGuestRc);
static bool waitResultImpliesEx(ProcessWaitResult_T waitResult, ProcessStatus_T procStatus, uint32_t uProcFlags, uint32_t uProtocol);
int writeData(uint32_t uHandle, uint32_t uFlags, void *pvData, size_t cbData, uint32_t uTimeoutMS, uint32_t *puWritten, int *pGuestRc);
/** @} */
/** @name Protected internal methods.
* @{ */
inline bool isAlive(void);
inline bool hasEnded(void);
/** @} */
/**
* This can safely be used without holding any locks.
* An AutoCaller suffices to prevent it being destroy while in use and
* internally there is a lock providing the necessary serialization.
*/
struct Data
{
/** The process startup information. */
/** Exit code if process has been terminated. */
/** PID reported from the guest. */
/** The current process status. */
/** The last returned process status
* returned from the guest side. */
int mLastError;
} mData;
};
/**
* Guest process tool flags.
*/
/** No flags specified. */
#define GUESTPROCESSTOOL_FLAG_NONE 0
/** Run until next stream block from stdout has been
* read in completely, then return.
*/
#define GUESTPROCESSTOOL_FLAG_STDOUT_BLOCK RT_BIT(0)
/**
* Internal class for handling a VBoxService tool ("vbox_ls", vbox_stat", ...).
*/
{
GuestProcessTool(void);
virtual ~GuestProcessTool(void);
int Init(GuestSession *pGuestSession, const GuestProcessStartupInfo &startupInfo, bool fAsync, int *pGuestRc);
bool IsRunning(void);
};
#endif /* !____H_GUESTPROCESSIMPL */