/** @SYMTestCaseID APPFWK-APPARC-0018 @SYMPREQ PREQ1123 @SYMTestCaseDesc The Test determines that a process is launched and terminated without any problem.\n @SYMTestPriority Low @SYMTestStatus Implemented @SYMTestActions. Creates and launches a process. No Child is created. Parent should launch properly, and on termination should die. API Calls:\n RProcess::Create(const TDesC &aFileName, const TDesC &aCommand, TOwnerType aType=EOwnerProcess);\n RProcess::Resume(); RProcess::ExitType() const; RProcess::ExitReason() const; RProcess::Id() const; RProcess::Terminate(TInt aReason); @SYMTestExpectedResults Proper creation and termination.\n */ void CT_ProcStep::testParentWithoutAChildL(void) { TInt ret(0) ; //process RProcess parentProc; ret = parentProc.Create(KParentExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(parentProc); INFO_PRINTF2(_L(" Create Parent Process returned : %d"),ret); TUint64 parentProcId=parentProc.Id(); INFO_PRINTF2(_L(" Process Id = 0x%lx "),parentProcId); INFO_PRINTF1(_L(" Run the Process ")); parentProc.Resume(); //Time for the parent process to launch itself User::After(5000000); TExitType exitType = parentProc.ExitType(); TEST(exitType == EExitKill||exitType == EExitPending); if(exitType==EExitPending) { INFO_PRINTF1(_L(" Process running normally ")); parentProc.Terminate(KTProcTerminatingParent); exitType = parentProc.ExitType(); TEST(exitType==EExitTerminate); TInt exitReason = parentProc.ExitReason(); TEST(exitReason == KTProcTerminatingParent); INFO_PRINTF1(_L(" Terminating the process ")); } CleanupStack::PopAndDestroy(&parentProc); }
// panic the client void CPicoServSession::PanicClient(TInt aPanic) const { Panic(_L("PicoN client"), aPanic); // client screwed up - there is nothing for us to do now RProcess me; me.Terminate(1); }
TInt MainL() { CSysMonTestHelper* helper = CSysMonTestHelper::NewLC(); TRecoveryMethod recoveryMethod = EIgnoreOnFailure; TInt recoveryMode = 0; helper->GetRecoveryMethodArgsL(recoveryMethod, recoveryMode); TBuf<KMaxTestIdLength> testId; helper->GetTestId(testId); TBuf<KMaxTestIdLength + 5> args; args.Append(testId); args.Append(_L(" ")); args.Append(_L("500")); //The length of time, in milliseconds, for the process to wait before deregistering RProcess slave; CleanupClosePushL(slave); TInt err = slave.Create(KFilenameDeregTimeout, args); // If we fail to create the process, pass the error code out to the test step and then leave helper->TestErrorcodeL(err); slave.Resume(); CStartupProperties* props = CStartupProperties::NewLC(KFilenameDeregTimeout, KNullDesC); props->SetMonitored(ETrue); props->SetStartupType(EStartProcess); props->SetStartMethod(EWaitForStart); props->SetNoOfRetries(1); props->SetTimeout(1000); props->SetRecoveryParams(recoveryMethod, recoveryMode); RSysMonSession sysmon; CleanupClosePushL(sysmon); TRAP(err, sysmon.OpenL()); // If we fail to connect, pass the error code out to the test step and then re-leave helper->TestErrorcodeL(err); // Register with SysMon TRAP(err, sysmon.MonitorL(*props, slave)); CleanupStack::PopAndDestroy(2,props); helper->WriteResultL(err); for (int i = 0; slave.ExitType() == EExitPending && i < 100; i++ ) // Wait for the process to end, or up to 1 second { User::After(10000); } if (slave.ExitType() == EExitPending) { slave.Terminate(KErrGeneral); } CleanupStack::PopAndDestroy(2, helper); return KErrNone; }
void CApaParentProcessMonitor::RunL() { // Do something that will kill the child when the parent process terminates if(iStatus==KErrNone) { RProcess proc; proc.Terminate(KErrNone); } }
CGameRunner::~CGameRunner() { Cancel(); RProcess process; if(process.Open(iProcessId) == KErrNone) { process.Terminate(1); process.Close(); } }
LOCAL_C void WaitForServerClose() { // Wait 10 seconds for server to exit TInt count = 10; while(count--) { TFullName name; TFindProcess find(KMsvServerPattern); if (find.Next(name) != KErrNone) return; else if (count <= 0) { RProcess process; process.Open(find); process.Terminate(KErrGeneral); process.Close(); } User::After(1000000); } }
/** Utility function to setup and start TErrMsgApp for the display of the error dialogs when the App leaves due to a call to CCoeEnv::LeaveWithErrorText() */ void CConeErrorMsgTestAppUi::TestErrorDialogL(const TDesC8& aTestCaseName, const TDesC& aTestCompareMbm, const TDesC* aDbgBmp, const TDesC* aDbgConvBmp, const TDesC* aDbgConvCompBmp, const TDesC* aDbgMbm) { _LIT(KExeName,"z:\\sys\\bin\\TErrMsgApp.EXE"); RProcess process; TRequestStatus status; TPtrC8 tailEnd; tailEnd.Set(aTestCaseName); // create and configure command line, with test case name in // the tail end to be used by TErrMsgApp to determine what // information is displayed in the error dialog CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); User::LeaveIfError(process.Create(KExeName, KNullDesC)); CleanupClosePushL(process); cmdLine->SetExecutableNameL(KExeName); cmdLine->SetTailEndL(tailEnd); cmdLine->SetProcessEnvironmentL(process); status = KRequestPending; process.Logon(status); process.Resume(); // allow the host process to start and display a dialog User::After(1000000); // screen capture CFbsBitmap* screenBitmap=new(ELeave) CFbsBitmap(); CleanupStack::PushL(screenBitmap); User::LeaveIfError(iWs.Connect()); CWsScreenDevice *actualScreen; actualScreen=new(ELeave) CWsScreenDevice(iWs); CleanupStack::PushL(actualScreen); User::LeaveIfError(actualScreen->Construct(0)); TSize screenSize=actualScreen->SizeInPixels(); TDisplayMode screenDisplayMode = actualScreen->DisplayMode(); User::LeaveIfError(screenBitmap->Create(screenSize, screenDisplayMode)); User::LeaveIfError(actualScreen->CopyScreenToBitmap(screenBitmap)); screenBitmap->Save(_L("c:\\screen.mbm")); // load in expected bmp for comparison CFbsBitmap* compareBitmap=new(ELeave) CFbsBitmap(); CleanupStack::PushL(compareBitmap); TInt loadErr = compareBitmap->Load(aTestCompareMbm); INFO_PRINTF3(_L("Load Error: %d Expected Error: %d"), loadErr, KErrNone); TEST(loadErr==KErrNone); // compare expected and actual bitmaps TInt lengthInBytes=screenBitmap->ScanLineLength(screenSize.iWidth, screenDisplayMode); HBufC8* lineBufBitmap=HBufC8::NewLC(lengthInBytes); TPtr8 lineBufBitmapPtr(lineBufBitmap->Des()); HBufC8* lineBufScreenBitmap=HBufC8::NewLC(lengthInBytes); TPtr8 lineBufScreenBitmapPtr(lineBufScreenBitmap->Des()); // in the case of the emulator the colour palette used by // windows can differ and therefore causes false failures to // be reported. e.g. although the dialog is displayed it is // subtly different shade of blue (techview), hence for // emulator test runs we purposely do not run a comparison // of the screen. #ifndef __WINS__ INFO_PRINTF1(_L("Comparing expected vs actual screen bitmap")); for (TInt index=0; index<screenSize.iHeight; index++) { compareBitmap->GetScanLine(lineBufBitmapPtr, TPoint(0,index), screenSize.iWidth, screenDisplayMode); screenBitmap->GetScanLine(lineBufScreenBitmapPtr, TPoint(0,index), screenSize.iWidth, screenDisplayMode); INFO_PRINTF2(_L("Scanline: %d"),index); TEST(lineBufBitmapPtr.Compare(lineBufScreenBitmapPtr)==0); } #endif if (aDbgMbm) { // for debug purposes store the screen capture // in c:\appfwk\test\cone\... User::LeaveIfError(iFs.Connect()); iFs.MkDirAll(*aDbgBmp); screenBitmap->Save(*aDbgBmp); const TDesC* bmpArray[1]; bmpArray[0] = aDbgBmp; TInt32 bmpIds[1]; bmpIds[0]=0; CFbsBitmap::StoreL(*aDbgMbm,1,bmpArray,bmpIds); // convert CFbsBitmap of screen capture to standard bmp to ease debug ConvertToBmpL(screenBitmap, aDbgConvBmp); // convert CFbsBitmap of expected bmp to standard bmp to ease debug ConvertToBmpL(compareBitmap, aDbgConvCompBmp); iFs.Close(); } // terminate the host process process.Terminate(KErrNone); CleanupStack::PopAndDestroy(7); iWs.Close(); // send signal to close a dialog CloseDialogsL(); // wait the host process for a termination User::WaitForRequest(status); }
/** @SYMTestCaseID APPFWK-APPARC-0020 @SYMPREQ PREQ1123 @SYMTestCaseDesc The Test determines that more than one Child for a Parent remain alive on their parent's termination. @SYMTestPriority Medium @SYMTestStatus Implemented @SYMTestActions. Creates and launches a process (parent). Creates 3 processes (child I,II,III) without passing the first (parent) process ID. Launches all the 3 processes. Terminates parent and checks the existance of the child processes. All 3 children should remain alive. API Calls:\n RProcess::Create(const TDesC &aFileName, const TDesC &aCommand, TOwnerType aType=EOwnerProcess);\n RProcess::Resume(); RProcess::ExitType() const; RProcess::ExitReason() const; RProcess::Id() const; RProcess::Terminate(TInt aReason); CApaCommandLine::SetProcessEnvironmentL(RProcess &aProcess) const; CApaCommandLine::NewLC(); @SYMTestExpectedResults Existence of all child processes.\n */ void CT_ProcStep::testNoChildSetToTerminateL(void) { TInt ret(0); //commandline for parent process CApaCommandLine* parentProcCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Parent Process created ")); //parent process RProcess parentProc; ret = parentProc.Create(KParentExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(parentProc); INFO_PRINTF2(_L(" Create Parent Process returned : %d"),ret); //attach commandline to parent process TRAP(ret,parentProcCmdln->SetProcessEnvironmentL(parentProc)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine to Process ")); INFO_PRINTF1(_L(" Run Parent Process ")); parentProc.Resume(); //Time for the parent process to launch itself User::After(500000); //commandline for child process //Get parent process ID here TUint64 parentProcId = parentProc.Id(); INFO_PRINTF2(_L(" Parent Process Id = 0x%lx "),parentProcId); //Child I CApaCommandLine* childProcOneCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Child One created ")); //child process RProcess childProcOne; ret = childProcOne.Create(KChildOneExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(childProcOne); INFO_PRINTF2(_L(" Create Child One returned : %d"),ret); //attach commandline to child process TRAP(ret,childProcOneCmdln->SetProcessEnvironmentL(childProcOne)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine of Child One to its Process ")); childProcOne.Resume(); //Time for the child process to launch itself User::After(1000000); //child process Id is reqd to monitor if it gets killed on its parent's termination TUint64 childProcOneId = childProcOne.Id(); INFO_PRINTF2(_L(" Child Process Id = 0x%lx "),childProcOneId); //Child II CApaCommandLine* childProcTwoCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Child Two created ")); //child process RProcess childProcTwo; ret = childProcTwo.Create(KChildTwoExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(childProcTwo); INFO_PRINTF2(_L(" Create Child Two returned : %d "),ret); //attach commandline to child process TRAP(ret,childProcTwoCmdln->SetProcessEnvironmentL(childProcTwo)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine of Child Two to its Process ")); INFO_PRINTF1(_L(" Run Child Two ")); childProcTwo.Resume(); //Time for the child process to launch itself User::After(1000000); //child process Id is reqd to monitor if it gets killed on its parent's termination TUint64 childProcTwoId = childProcTwo.Id(); INFO_PRINTF2(_L(" Child Two Id = 0x%lx "),childProcTwoId); //Child III CApaCommandLine* childProcThreeCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Child Three created ")); //child process RProcess childProcThree; ret = childProcThree.Create(KChildThreeExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(childProcThree); INFO_PRINTF2(_L(" Create Child Three returned : %d"),ret); //attach commandline to child process TRAP(ret,childProcThreeCmdln->SetProcessEnvironmentL(childProcThree)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine of Child Three to its Process ")); childProcThree.Resume(); //Time for the child process to launch itself User::After(1000000); //child process Id is reqd to monitor if it gets killed on its parent's termination TUint64 childProcThreeId = childProcThree.Id(); INFO_PRINTF2(_L(" Child Three Id = 0x%lx "),childProcThreeId); parentProc.Terminate(KTProcTerminatingParent); TExitType exitType = parentProc.ExitType(); TEST(exitType == EExitTerminate); TInt exitReason = parentProc.ExitReason(); TEST(exitReason == KTProcTerminatingParent); INFO_PRINTF1(_L(" Terminating parent process ")); //Time for the child processes to terminate if they really do User::After(500000); exitType = childProcOne.ExitType(); TEST(exitType == EExitPending); if(exitType == EExitPending) { INFO_PRINTF1(_L(" Child I is still running ")); INFO_PRINTF1(_L(" So Terminating it manually ... ")); childProcOne.Terminate(KTProcTerminatingChildI); exitType = childProcOne.ExitType(); TEST(exitType==EExitTerminate); exitReason = childProcOne.ExitReason(); TEST(exitReason == KTProcTerminatingChildI); } exitType = childProcTwo.ExitType(); TEST(exitType == EExitPending); if(exitType == EExitPending) { INFO_PRINTF1(_L(" Child II is still running ")); INFO_PRINTF1(_L(" So Terminating it manually ... ")); childProcTwo.Terminate(KTProcTerminatingChildII); exitType = childProcTwo.ExitType(); TEST(exitType==EExitTerminate); exitReason = childProcTwo.ExitReason(); TEST(exitReason == KTProcTerminatingChildII); } exitType = childProcThree.ExitType(); TEST(exitType == EExitPending); if(exitType == EExitPending) { INFO_PRINTF1(_L(" Child III is still running ")); INFO_PRINTF1(_L(" So Terminating it manually ... ")); childProcThree.Terminate(KTProcTerminatingChildIII); exitType = childProcThree.ExitType(); TEST(exitType==EExitTerminate); exitReason = childProcThree.ExitReason(); TEST(exitReason == KTProcTerminatingChildIII); } CleanupStack::PopAndDestroy(&childProcThree); CleanupStack::PopAndDestroy(childProcThreeCmdln); CleanupStack::PopAndDestroy(&childProcTwo); CleanupStack::PopAndDestroy(childProcTwoCmdln); CleanupStack::PopAndDestroy(&childProcOne); CleanupStack::PopAndDestroy(childProcOneCmdln); CleanupStack::PopAndDestroy(&parentProc); CleanupStack::PopAndDestroy(parentProcCmdln); }
/** @SYMTestCaseID APPFWK-APPARC-0017 @SYMPREQ PREQ1123 @SYMTestCaseDesc Test determines that one Child remains and another terminates when their Parent terminates, based on their creation. @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions. Creates and launches a process (parent). Creates a process (child I) passing the first (parent) process ID. Creates a second process (child II) without passing the first (parent) process ID. Launches both the child processes. Terminates parent and checks the existance of both the child processes. Child I should die and Child II should remain alive. API Calls:\n RProcess::Create(const TDesC &aFileName, const TDesC &aCommand, TOwnerType aType=EOwnerProcess);\n RProcess::Resume(); RProcess::ExitType() const; RProcess::ExitReason() const; RProcess::Id() const; RProcess::Terminate(TInt aReason); CApaCommandLine::SetProcessEnvironmentL(RProcess &aProcess) const; CApaCommandLine::NewLC(); CApaCommandLine::SetParentProcessId(TProcessId); @SYMTestExpectedResults Termination of first child process and existence of the second.\n */ void CT_ProcStep::testTwoChildsOneToTerminateAndOtherToRemainL(void) { TInt ret(0); TExitType exitType; //commandline for parent process CApaCommandLine* parentProcCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Parent Process created ")); //parent process RProcess parentProc; ret = parentProc.Create(KParentExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(parentProc); INFO_PRINTF2(_L(" Create Parent Process returned : %d"),ret); //attach commandline to parent process TRAP(ret,parentProcCmdln->SetProcessEnvironmentL(parentProc)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine to Process ")); INFO_PRINTF1(_L(" Run Parent Process ")); parentProc.Resume(); //Time for the parent process to launch itself User::After(500000); //commandline for child process //Get parent process ID here TUint64 parentProcId = parentProc.Id(); INFO_PRINTF2(_L(" Parent Process Id = 0x%lx"),parentProcId); //For Child ONE CApaCommandLine* childProcOneCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Child One created ")); //setting the parent process ID to child I childProcOneCmdln->SetParentProcessId(parentProcId); INFO_PRINTF1(_L(" Set ParentProcessId to Child One ")); //child process ONE RProcess childProcOne; ret = childProcOne.Create(KChildOneExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(childProcOne); INFO_PRINTF2(_L(" Create Child One returned : %d"),ret); //attach commandline to child process TRAP(ret,childProcOneCmdln->SetProcessEnvironmentL(childProcOne)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine of Child One to its Process ")); INFO_PRINTF1(_L(" Run Child One ")); childProcOne.Resume(); //Time for the child one to launch itself User::After(500000); //child process Id is reqd to monitor if it gets killed on its parent's termination TUint64 childProcOneId = childProcOne.Id(); INFO_PRINTF2(_L(" Child One Id = 0x%lx "),childProcOneId); //For Child TWO CApaCommandLine* childProcTwoCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Child Two created ")); //child process TWO RProcess childProcTwo; ret = childProcTwo.Create(KChildTwoExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(childProcTwo); INFO_PRINTF2(_L(" Create Child Two returned : %d"),ret); //attach commandline to child process TRAP(ret,childProcTwoCmdln->SetProcessEnvironmentL(childProcTwo)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine of Child Two to its Process ")); INFO_PRINTF1(_L(" Run Child Two ")); childProcTwo.Resume(); //Time for the child one to launch itself User::After(500000); //child II process Id is reqd to monitor if it gets killed on its parent's termination TUint64 childProcTwoId = childProcTwo.Id(); INFO_PRINTF2(_L(" Child Two Id = 0x%lx "),childProcTwoId); CChildProcess* childProcess=NULL; TRAP(ret, childProcess=CChildProcess::NewL(parentProc,childProcOneId)); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupStack::PushL(childProcess); exitType = parentProc.ExitType(); TEST(exitType == EExitTerminate); TInt exitReason = parentProc.ExitReason(); TEST(exitReason == 0); if(exitType==EExitTerminate && exitReason==0) { INFO_PRINTF1(_L(" Parent process is Terminated")); } exitType = childProcOne.ExitType(); TEST(exitType == EExitTerminate); exitReason = childProcOne.ExitReason(); TEST(exitReason == 0); if(exitType==EExitTerminate && exitReason==0) { INFO_PRINTF1(_L(" Child I is killed automatically ... ")); } //Wait and see if child II terminates automatically... User::After(10000000); exitType = childProcTwo.ExitType(); TEST(exitType == EExitPending); if(exitType==EExitPending) { INFO_PRINTF1(_L(" Child II running successfully")); childProcTwo.Terminate(KTProcTerminatingChildII); exitType = childProcTwo.ExitType(); TEST(exitType==EExitTerminate); exitReason = childProcTwo.ExitReason(); TEST(exitReason == KTProcTerminatingChildII); INFO_PRINTF1(_L(" So Terminated it manually ...")); } CleanupStack::PopAndDestroy(childProcess); CleanupStack::PopAndDestroy(&childProcTwo); CleanupStack::PopAndDestroy(childProcTwoCmdln); CleanupStack::PopAndDestroy(&childProcOne); CleanupStack::PopAndDestroy(childProcOneCmdln); CleanupStack::PopAndDestroy(&parentProc); CleanupStack::PopAndDestroy(parentProcCmdln); }
/** @SYMTestCaseID APPFWK-APPARC-0022 @SYMPREQ PREQ1123 @SYMTestCaseDesc The Test determines that the child doesn't receive its parent process ID correctly, when not set during its creation. @SYMTestPriority Medium @SYMTestStatus Implemented @SYMTestActions. Creates and launches a process (parent). Creates another process (child) without setting any parent. Parent Process Id is passed to child through SetParameter API. Launches the child process. Child obtains the parent process Id from within. Child compares both the Id's. The Id's should not match each other. API Calls:\n RProcess::Create(const TDesC &aFileName, const TDesC &aCommand, TOwnerType aType=EOwnerProcess);\n RProcess::Resume(); RProcess::ExitType() const; RProcess::ExitReason() const; RProcess::Id() const; RProcess::SetParameter(TInt aSlot, TInt aData); CApaCommandLine::SetProcessEnvironmentL(RProcess &aProcess) const; CApaCommandLine::NewLC(); RFile::Open(RFs &aFs, const TDesC &aName, TUint aFileMode); RFile::Read(TInt aPos, TDes8 &aDes) const; RFile::Close(); RFs::Connect(TInt aMessageSlots=KFileServerDefaultMessageSlots); RFs::Delete(const TDesC &aName); RFs::Close(); @SYMTestExpectedResults Id received by child process should not match its parent process Id.\n */ void CT_ProcStep::testIdNotAvailableToChildL(void) { TInt ret(0); TInt exitReason(0); //commandline for parent process CApaCommandLine* parentProcCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Parent Process created ")); //parent process RProcess parentProc; ret = parentProc.Create(KParentExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(parentProc); INFO_PRINTF2(_L(" Create Parent Process returned : %d"),ret); //attach commandline to parent process TRAP(ret,parentProcCmdln->SetProcessEnvironmentL(parentProc)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine to Process ")); INFO_PRINTF1(_L(" Run Parent Process ")); parentProc.Resume(); //Time for the parent process to launch itself User::After(500000); //commandline for child process //Get parent process ID here TUint64 parentProcId = parentProc.Id(); INFO_PRINTF2(_L(" Parent Process Id = 0x%lx "),parentProcId); CApaCommandLine* childProcCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Child Process created ")); //child process RProcess childProc; ret = childProc.Create(KChildThreeExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(childProc); INFO_PRINTF2(_L(" Create Child Process returned : %d"),ret); //attach commandline to child process TRAP(ret,childProcCmdln->SetProcessEnvironmentL(childProc)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine to Process ")); //Setting the parent process Id in an environment slot for the child to receive. ret = childProc.SetParameter(12,parentProcId); TEST(ret == KErrNone); INFO_PRINTF2(_L(" Set the Parent Process Id - 0x%lx to Child through SetParameter API in Slot 12 "),parentProcId); INFO_PRINTF1(_L(" Run Child Process ")); TRequestStatus status; childProc.Rendezvous(status); childProc.Resume(); //Wait for the child process to launch itself User::WaitForRequest(status); RFs fs; RFile file; ret = fs.Connect(); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Create File server session ")); ret = file.Open(fs,KFilePath,EFileWrite | EFileShareAny); TEST(ret == KErrNone); if(ret == KErrNone) { INFO_PRINTF1(_L(" File opened successfully ")); TBuf8<5> readData; file.Read(0,readData); TBuf8<5> result(KTResultFail); TEST(result==readData); if(result==readData) { INFO_PRINTF1(_L(" Child did not receive the parent process ID as intended...")); } else { INFO_PRINTF1(_L(" Child received the Wrong parent process ID ...")); } file.Close(); fs.Delete(KFilePath); fs.Close(); INFO_PRINTF1(_L(" File Close & Delete and Session Close ")); } TExitType exitType = parentProc.ExitType(); TEST(exitType == EExitPending); if(exitType == EExitPending) { INFO_PRINTF1(_L(" Parent is still running ")); INFO_PRINTF1(_L(" So Terminating it manually ... ")); parentProc.Terminate(KTProcTerminatingParent); exitType = parentProc.ExitType(); TEST(exitType==EExitTerminate); exitReason = parentProc.ExitReason(); TEST(exitReason == KTProcTerminatingParent); } exitType = childProc.ExitType(); TEST(exitType == EExitPending); if(exitType == EExitPending) { INFO_PRINTF1(_L(" Child is still running ")); INFO_PRINTF1(_L(" So Terminating it manually ... ")); childProc.Terminate(KTProcTerminatingChildIII); exitType = childProc.ExitType(); TEST(exitType==EExitTerminate); exitReason = childProc.ExitReason(); TEST(exitReason == KTProcTerminatingChildIII); } CleanupStack::PopAndDestroy(&childProc); CleanupStack::PopAndDestroy(childProcCmdln); CleanupStack::PopAndDestroy(&parentProc); CleanupStack::PopAndDestroy(parentProcCmdln); }