Hi to all!

When im trying to start application from my appliocation like this:

TInt CMyClass::StartApp(TFileName fileName, TInt flag)
{
TFileName fnAppPath = fileName;
RFs fsSession; //file server session
User::LeaveIfError(fsSession.Connect());
CleanupClosePushL(fsSession);
TFindFile findFile( fsSession );
User::LeaveIfError( findFile.FindByDir(fnAppPath, KNullDesC) );
CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
cmdLine->SetLibraryNameL( findFile.File() );

switch (flag)
{
case 0:
cmdLine->SetCommandL( EApaCommandBackground );
break;
case 1:
cmdLine->SetCommandL( EApaCommandRun );
break;
default:
cmdLine->SetCommandL( EApaCommandBackground );
break;
}

RApaLsSession ls;
User::LeaveIfError(ls.Connect());
CleanupClosePushL(ls);
User::LeaveIfError( ls.StartApp(*cmdLine) );
CleanupStack::PopAndDestroy(3);

return 1;
}

or like this:

TInt CMyClass::StartProcess(TDesC& aPath,TDesC& aCommand)
{
RProcess proc;
CleanupClosePushL(proc);
TInt err = proc.Create(aPath,aCommand);
proc.Resume();
CleanupStack::PopAndDestroy();
return err;
}
where aPath = _L("z:\\system\\programs\\apprun.exe") and aCommand is path af app to be started.

When i'm closing application that i'va started my application is closed to and seems to me with no panic code.

It seems to me that when i'm startring application it's thread becomes owned by my main application.

How can i resolve this? Thanks