|
1 // Copyright (c) 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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <f32file.h> |
|
17 #include <e32debug.h> |
|
18 |
|
19 //This function is used in the test code to kill ECOMSERVER |
|
20 //processes (or some other) when they leftover and may problem in ECOMSERVERTEST |
|
21 static TInt KillProcess(const TDesC& aProcessName) |
|
22 { |
|
23 TFullName name; |
|
24 |
|
25 RDebug::Print(_L("Find and kill \"%S\" process.\n"), &aProcessName); |
|
26 |
|
27 TBuf<64> pattern(aProcessName); |
|
28 TInt length = pattern.Length(); |
|
29 pattern += _L("*"); |
|
30 TFindProcess procFinder(pattern); |
|
31 |
|
32 while(procFinder.Next(name) == KErrNone) |
|
33 { |
|
34 if(name.Length() > length) |
|
35 { |
|
36 //If found name is a string containing aProcessName string. |
|
37 TChar c(name[length]); |
|
38 if(c.IsAlphaDigit() || c == TChar('_') || c == TChar('-')) |
|
39 { |
|
40 //If the found name is other valid application name starting with aProcessName string. |
|
41 RDebug::Print(_L(":: Process name: \"%S\".\n"), &name); |
|
42 continue; |
|
43 } |
|
44 } |
|
45 RProcess proc; |
|
46 if(proc.Open(name) == KErrNone) |
|
47 { |
|
48 proc.Kill(0); |
|
49 RDebug::Print(_L("\"%S\" process killed.\n"), &name); |
|
50 } |
|
51 proc.Close(); |
|
52 } |
|
53 return KErrNone; |
|
54 } |
|
55 |
|
56 GLDEF_C TInt E32Main() |
|
57 { |
|
58 TFileName name; |
|
59 User::CommandLine(name); |
|
60 return KillProcess(name); |
|
61 } |
|
62 |