Skip to content

Commit

Permalink
Limit number of attempts for killing processes
Browse files Browse the repository at this point in the history
  • Loading branch information
lakeman committed Nov 8, 2012
1 parent 5832f55 commit b30ca06
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/org/servalproject/system/CoreTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.servalproject.shell.Shell;

import android.content.SharedPreferences.Editor;
import android.os.SystemClock;
import android.util.Log;

public class CoreTask {
Expand Down Expand Up @@ -223,9 +224,14 @@ public void killProcess(String processName, boolean root)
throws IOException {
// try to kill running processes by name
int pid, lastPid = -1;
long timeout = SystemClock.elapsedRealtime() + 3000;
Shell shell = root ? Shell.startRootShell() : Shell.startShell();
try {
while ((pid = getPid(processName)) >= 0) {
if (timeout <= SystemClock.elapsedRealtime()) {
Log.v("BatPhone", "Giving up");
break;
}
if (pid != lastPid) {
try {
Log.v("BatPhone", "Killing " + processName + " pid "
Expand Down

0 comments on commit b30ca06

Please sign in to comment.