void KviKvsProcessAsyncOperation::readStderr()
{
	if(m_bDeletePending)
		return;
	if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_OUTPUTBYBLOCKS)
	{
		QByteArray a = m_pProcess->readAllStandardError();
		if(a.size() > 0)
			m_szStderrBuffer += QString(a);
	}
	else
	{
		m_pProcess->setReadChannel(QProcess::StandardError);
		QString l;
		bool bBreak = false;
		while((m_pProcess->canReadLine()) && (!bBreak))
		{
			l = m_pProcess->readLine();

			if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTDERR)
			{
				if(trigger(EventStderr, l))
				{
					bBreak = true;
					triggerSelfDelete();
				}
			}
		}
	}
}
void KviKvsProcessAsyncOperation::ping()
{
	if(trigger(EventPing, QString()))
	{
		triggerSelfDelete();
	}
}
Example #3
0
void KviKvsProcessAsyncOperation::processStarted()
{
    if(m_bDeletePending)return;

    QString szPid;
    szPid.setNum((int)(m_pProcess->pid()));
    if(trigger(EventStarted,szPid))
    {
        triggerSelfDelete();
        return;
    }
}
void KviKvsProcessAsyncOperation::processExited(int exitCode)
{
	if(m_bDeletePending)
		return;

	readStdout(); // just to make sure
	readStderr(); // just to make sure

	if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_OUTPUTBYBLOCKS)
	{
		// trigger Stdout and Stderr once
		if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTDOUT)
		{
			if(trigger(EventStdout, m_szStdoutBuffer))
			{
				triggerSelfDelete();
				return;
			}
		}

		if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERSTDERR)
		{
			if(trigger(EventStdout, m_szStderrBuffer))
			{
				triggerSelfDelete();
				return;
			}
		}
	}

	if(m_pData->iFlags & KVI_KVS_PROCESSDESCRIPTOR_TRIGGERTERMINATED)
	{
		QString szRetVal;
		szRetVal.setNum(exitCode);
		trigger(EventTerminated, szRetVal);
	}

	triggerSelfDelete();
}
void KviKvsProcessAsyncOperation::maxRunTimeExpired()
{
	trigger(EventTerminated, "0");
	triggerSelfDelete();
}