rpatel8624 / alogcat

Automatically exported from code.google.com/p/alogcat
0 stars 0 forks source link

logcat processes keep running on phone #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Start aLogcat
2. Exit aLogcat (eg. by pressing Back button)
3. Check with "adb shell ps" for running 'logcat' processes

What is the expected output? What do you see instead?
No logcat process started by aLogcat should be running.

What version of the product are you using? On what operating system?
1.3.4 on a HTC Hero (Android 1.5)

Please provide any additional information below.
As I understand aLogcat starts 'logcat' processes on the phone, to obtain
the log messages. 

For a clean shutdown it should either:
--------------------------------------
- kill the created processes itself (maybe in onPause() or on click to a
dedicated exit button?)

- or take care that the Android kernel's internal lowmemory killer can kill
the processes by setting the oom_adj value of the process accordingly (as
per default the processes get an oom_adj value of 0 which is the same as
FOREGROUND_APP so the lowmemory killer never will kill these processes.

For both options you need to know the PID of the spawn child processes.
It's possible to retrieve iT on Android by using reflection:

// start child process
java.lang.Process process = Runtime.getRuntime().exec( ... );

// try to get PID of child logcat process (for later killing)
int childPid = -1;
if (android.os.Process.supportsProcesses() &&
process.getClass().getName().equals("java.lang.ProcessManager$ProcessImpl")) {
  try {
    Field f = process.getClass().getDeclaredField("id");
    f.setAccessible(true);
    childPid = f.getInt(process);
  } catch (Throwable e) {
    childPid = -1;
  }
}

Original issue reported on code.google.com by johannes...@gmail.com on 26 Jan 2010 at 8:28

GoogleCodeExporter commented 8 years ago
this is fixed as of the latest release, although i handled it slightly 
different. i keep a handle to the Process object 
used to open the logcat command, and then call destroy() on it whenever the app 
is paused. when the app is 
resumed(), it restarts again with a new Process. this seems simpler than what 
you have above, although i am not 
sure if i am missing anything.

i am closing this issue. if you feel that it is not fixed correctly, please 
re-open / let me know.

Original comment by jeffrey.blattman@gmail.com on 31 Mar 2010 at 10:27

GoogleCodeExporter commented 8 years ago
Thanks! :-)

Tested on my HTC Hero and seems to work correctly now!

Original comment by johannes...@gmail.com on 10 Apr 2010 at 9:05