Prevent logcat monitors crashing

This commit is contained in:
topjohnwu
2017-07-16 03:54:06 +08:00
parent a87ad35a50
commit 6072744f7e
4 changed files with 14 additions and 7 deletions

View File

@@ -180,7 +180,10 @@ void proc_monitor() {
while (1) {
// Clear previous logcat buffer
system("logcat -b events -c");
char *const restart[] = { "logcat", "-b", "events", "-c", NULL };
log_pid = run_command(0, NULL, "/system/bin/logcat", restart);
if (log_pid > 0)
waitpid(log_pid, NULL, 0);
// Monitor am_proc_start
char *const command[] = { "logcat", "-b", "events", "-v", "raw", "-s", "am_proc_start", NULL };
@@ -269,6 +272,5 @@ void proc_monitor() {
kill(log_pid, SIGTERM);
waitpid(log_pid, NULL, 0);
close(log_fd);
log_pid = 0;
}
}