sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Tprocesskiller.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: //This function is used in the test code to kill SCHSVR or MinimalTaskHandler sl@0: //processes (or some other) when they leftover and may cause OOM condinitons. sl@0: static TInt DeleteScheduleFilesL() sl@0: { sl@0: RFs fs; sl@0: _LIT(KFilePath, "_:\\Private\\10005399\\*.*"); sl@0: sl@0: //Get the correct system drive sl@0: TBuf<32> filePath(KFilePath); sl@0: filePath[0] = RFs::GetSystemDriveChar(); sl@0: sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: CFileMan* fileManager = CFileMan::NewL(fs); sl@0: CleanupStack::PushL(fileManager); sl@0: TInt ret = fileManager->Delete(filePath); sl@0: if(ret != KErrNone && ret != KErrNotFound && ret != KErrPathNotFound) sl@0: { sl@0: RDebug::Print(_L("DeleteScheduleFilesL - err=%d\n"), ret); sl@0: //Resource/memory/file deallocation is not the right place for User::Leave() call! sl@0: //Sometimes fileManager->Delete() fails with error "-14" (KErrInUse), sl@0: //because SCHSVR server is alive! sl@0: //User::Leave(ret); sl@0: } sl@0: CleanupStack::PopAndDestroy(fileManager); sl@0: CleanupStack::PopAndDestroy(); //fs sl@0: return KErrNone; sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TInt err = KErrNoMemory; sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); //can fail sl@0: if (cleanup) sl@0: { sl@0: err = KErrNone; sl@0: TRAP(err, DeleteScheduleFilesL()) sl@0: delete cleanup; sl@0: } sl@0: return err; sl@0: } sl@0: