Hi,
I have to run and exe from an application and also need to get notified when the exe exits normally or otherwise. In order to monitor the process termination i have used RProcess::Logon(); RProcess::Resume; then SetActive(), so that the monitoring happens in an asynchronous manner in an AO. I dont have any problems uptill now.
Now, I also need to stop the process(launched exe) in the midway by pressing stop option within OPTIONS. So I have used a Message queue to pass strings to the process. I am also able to stop the process in the midway.
Now, the problem....after i have started the exe from my app, obvoiusly it starts running. But while exe runs and i hit the OPTIONS soft key, My options pop up(which is ofcourse ok) and the RunL() of the active object which i use to handle process termination is hit (this should not happen, that too with iStatus.Int() value being KErrNone) although the process still runs,showing that the process is alive. Hence, after RunL() is hit and no farther process termination notification is possible.
Why the outstanding RProcess::Logon() request is forcibly completed ??(while the exe is still runs) with iStatus being KErrNone and execution hits RunL() when i hit the OPTIONS softkey? any idea? This is a Little but very tricky problem.
Here are the codes:
In the Calling Application:
void CProcessMonitor::MonitorL()//For launching the exe and monitoring it
{
TBuf<100> commandline;
TBuf<100> KFileName;
commandline.Copy(iCGetRunFileAppPropertyWatch->GetPropertyHandle());
TInt len=ExeNameArray->MdcaCount();
if((len!=0)&&(Index<len))
{
KFileName.Copy(ExeNameArray->MdcaPoint(Index));
TInt err1=iMonitor.Create(KFileName, commandline,EOwnerProcess);
if(err1 != KErrNone)
{
CAknErrorNote* iMyErrorNote;
iMyErrorNote= new (ELeave) CAknErrorNote;
iMyErrorNote->ExecuteLD(_L("Failed to Create Process"));
iMonitor.Close();
User::Leave(err1);
}
iMonitor.Logon(iStatus);
iMonitor.Resume();
Index++;
SetActive();
}
else
Index=0;
}
void CProcessMonitor::RunL()
{
if(iStatus.Int()==KErrNone)
{
if(iMonitor.ExitType()==EExitPanic)
{
//****This piece of code for panic description************
CAknErrorNote* iMyErrorNote;
iMyErrorNote= new (ELeave) CAknErrorNote;
TBuf<40> msg(_L("Process Panicked:"));
msg.Append(iMonitor.ExitCategory());
msg.Append(_L("-"));
msg.AppendNum(iMonitor.ExitReason());
iMyErrorNote->ExecuteLD(msg);
}
else
{
//****This piece of code for normal process termination****
//Note: This section is hit in this problem, it shows output as an error note "Process exit status: 30 in handset"
CAknErrorNote* iMyErrorNote;
iMyErrorNote= new (ELeave) CAknErrorNote;
TBuf<50> error(_L("Process exit status:"));
error.AppendNum(iMonitor.ExitType());//process is active:value 3 in output
error.AppendNum(iStatus.Int());//value 0 ??
iMyErrorNote->ExecuteLD(error);
if(ExecuteNext)//set the variable ExecuteNext=ETrue if next process is to be executed
//set this variable to EFalse if the current process needs to be stopped by loader
MonitorL();//Starts the next Process
}
}
iMonitor.Close();
}
and
Here is the HandleCommandL():
void CGetRunFileAppAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyBack:
case EEikCmdExit:
{
Exit();
break;
}
case EGetRunFileAppCmdGet:
{
// Nothing
break;
}
case EGetRunFileAppCmdRun:
{
// iEikonEnv->InfoMsg(_L("test"));
iAppContainer->StartRunProcessL(); //calls the CProcessMonitor::MonitorL()
break;
}
case EGetRunFileAppCmdStop:
{
//to be added later
// iEikonEnv->InfoMsg(_L("test"));
ControlQueue.Send(_L8("STOP"));
break;
}
// TODO: Add Your command handling code here
default:
break;
}
}
I dont find the codes of called exe related to this problem as the called exe runs and terminates as required, the problem is there in calling application that launches it.
Can Anyone help this peculiar problem of mine???
Thanks a lot for being patient and reading so much, i hope i have communicated the problem properly.
Please do help.
Thanks,
Arunangshu

Reply With Quote

