Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logcat processes keep running on phone #2

Closed
GoogleCodeExporter opened this issue Dec 14, 2015 · 2 comments
Closed

logcat processes keep running on phone #2

GoogleCodeExporter opened this issue Dec 14, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant