// resume the exe and if compatibility mode is available, check that the // expected outcome of the test loop was observed (check 2) // delete it afterward. void DoStopExe(RProcess& p, TInt aExpectedUnsafe) { TRequestStatus s; p.Logon(s); p.Resume(); User::WaitForRequest(s); if (CompatMode) test_Equal(aExpectedUnsafe ? 1 : 0, s.Int()); test_Equal(EExitKill, p.ExitType()); p.NotifyDestruction(s); p.Close(); User::WaitForRequest(s); }
void CTestStepESockSSA::KillC32Start() { // Start by looking for the running configurator and kill it if found. The caller // needs the appropriate capability to do this RDebug::Printf("Finding existing configurator process."); _LIT(KC32StartName, "*"); TInt result; TBool configuratorWasPresent; TInt count = 0; const TInt KMaxKillRetry = 10; do { configuratorWasPresent = EFalse; TFullName fn; TFindProcess fp(KC32StartName); while(fp.Next(fn) == KErrNone) { RProcess proc; result = proc.Open(fn); if(result == KErrNone) { TUidType type = proc.Type(); if(type[2] == TUid::Uid(KUidC32StartProcess) && proc.ExitType() == EExitPending) { // Kill the existing configurator process. RDebug::Print(_L("Opened existing configurator process \"%S\""), &fn); TRequestStatus status; proc.Logon(status); proc.Kill(KErrNone); RDebug::Printf("Killed process."); User::WaitForRequest(status); TExitType exitType = proc.ExitType(); // Create a timer in case some other entity holds an open handle on the // configurator which prevents the kernel from destroying it. We timeout // after one second. TAutoClose<RTimer> timer; if(timer.iObj.CreateLocal() == KErrNone) { // Request destruction notification so we know when it is safe to start // the process again. TRequestStatus destructionStatus; proc.NotifyDestruction(destructionStatus); proc.Close(); enum{ KProcessDestructionTimeout = 1000000 }; TRequestStatus timerStatus; timer.iObj.After(timerStatus, KProcessDestructionTimeout); // Wait for the process to be destroyed or for the timeout. User::WaitForRequest(destructionStatus, timerStatus); if(timerStatus.Int() == KRequestPending) { timer.iObj.Cancel(); User::WaitForRequest(timerStatus); } else { User::CancelMiscNotifier(destructionStatus); User::WaitForRequest(destructionStatus); RDebug::Printf("Existing configurator process has still not been destroyed after %f.0s", KProcessDestructionTimeout / 1000000.0); } } else { proc.Close(); } RDebug::Printf("Process logon completed with %d, exitType %d", status.Int(), exitType); configuratorWasPresent = ETrue; } else { proc.Close(); } } } } while(configuratorWasPresent && ++count < KMaxKillRetry); if (count >= KMaxKillRetry) { RDebug::Printf("KillC32Start - Cannot kill the configurator process, we will try continue and hope all is well"); } // Restart the boot sequence from scratch - the configurator reads this. RProperty::Set(KUidSystemCategory, KUidC32StartPropertyKey.iUid, EReset); }