Simplify patch by using GetProcessId

GetProcessId simplifies the code as it avoids to add the additional member variable 'm_childProcessId'. Cleaned up the indentation.
This commit is contained in:
Uwe Stieber 2013-09-24 13:11:48 +02:00
parent 03fbed5fc2
commit d6498a63b8
2 changed files with 4 additions and 6 deletions

View File

@ -57,7 +57,6 @@ Agent::Agent(LPCWSTR controlPipeName,
m_terminal(NULL),
m_childProcess(NULL),
m_childExitCode(-1),
m_childProcessId(-1),
m_syncCounter(0)
{
trace("Agent starting...");
@ -187,7 +186,10 @@ void Agent::handlePacket(ReadBuffer &packet)
break;
case AgentMsg::GetProcessId:
ASSERT(packet.eof());
result = m_childProcessId;
if (m_childProcess == NULL)
result = -1;
else
result = GetProcessId(m_childProcess);
break;
default:
trace("Unrecognized message, id:%d", type);
@ -199,7 +201,6 @@ int Agent::handleStartProcessPacket(ReadBuffer &packet)
{
BOOL success;
ASSERT(m_childProcess == NULL);
ASSERT(m_childProcessId == -1);
std::wstring program = packet.getWString();
std::wstring cmdline = packet.getWString();
@ -241,7 +242,6 @@ int Agent::handleStartProcessPacket(ReadBuffer &packet)
if (success) {
CloseHandle(pi.hThread);
m_childProcess = pi.hProcess;
m_childProcessId = (int)pi.dwProcessId;
}
return ret;
@ -283,7 +283,6 @@ void Agent::onPollTimeout()
m_childExitCode = exitCode;
CloseHandle(m_childProcess);
m_childProcess = NULL;
m_childProcessId = -1;
// Close the data socket to signal to the client that the child
// process has exited. If there's any data left to send, send it

View File

@ -79,7 +79,6 @@ private:
ConsoleInput *m_consoleInput;
HANDLE m_childProcess;
int m_childExitCode;
int m_childProcessId;
int m_syncRow;
int m_syncCounter;