Update contrib.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 //This function is used in the test code to kill SCHSVR or MinimalTaskHandler
20 //processes (or some other) when they leftover and may cause OOM condinitons.
21 static TInt KillProcess(const TDesC& aProcessName)
24 TInt err = KErrNotFound;
26 RDebug::Print(_L("Find and kill \"%S\" process.\n"), &aProcessName);
28 TBuf<64> pattern(aProcessName);
29 TInt length = pattern.Length();
31 TFindProcess procFinder(pattern);
33 while(procFinder.Next(name) == KErrNone)
35 if(name.Length() > length)
36 {//If found name is a string containing aProcessName string.
37 TChar c(name[length]);
38 if(c.IsAlphaDigit() || c == TChar('_') || c == TChar('-'))
39 {//If the found name is other valid application name starting with aProcessName string.
40 RDebug::Print(_L(":: Process name: \"%S\".\n"), &name);
46 err = proc.Open(name);
50 //If the process is alive, terminate it
51 if(proc.ExitType() == EExitPending)
54 RDebug::Print(_L("\"%S\" process killed.\n"), &name);
57 //If the process has already died record the error
66 GLDEF_C TInt E32Main()
69 User::CommandLine(name);
70 return KillProcess(name);