mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 13:47:38 +00:00
Fix SEGFAULT in magisk log dumper
This commit is contained in:
parent
c7e777255a
commit
28a945fee9
@ -25,6 +25,8 @@ static void *logger_thread(void *args) {
|
|||||||
int log_fd = -1, log_pid;
|
int log_fd = -1, log_pid;
|
||||||
char line[4096];
|
char line[4096];
|
||||||
|
|
||||||
|
LOGD("log_monitor: logger start");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// Start logcat
|
// Start logcat
|
||||||
log_pid = exec_command(0, &log_fd, NULL, "logcat", "-b", "all" , "-v", "threadtime", "-s", "am_proc_start", "Magisk", NULL);
|
log_pid = exec_command(0, &log_fd, NULL, "logcat", "-b", "all" , "-v", "threadtime", "-s", "am_proc_start", "Magisk", NULL);
|
||||||
@ -61,6 +63,8 @@ static void *magisk_log_thread(void *args) {
|
|||||||
// Register our listener
|
// Register our listener
|
||||||
logcat_events[LOG_EVENT] = pipefd[1];
|
logcat_events[LOG_EVENT] = pipefd[1];
|
||||||
|
|
||||||
|
LOGD("log_monitor: magisk log dumper start");
|
||||||
|
|
||||||
for (char *line; xxread(pipefd[0], &line, sizeof(line)) > 0; free(line)) {
|
for (char *line; xxread(pipefd[0], &line, sizeof(line)) > 0; free(line)) {
|
||||||
char *ss;
|
char *ss;
|
||||||
if ((ss = strstr(line, " Magisk")) && (ss[-1] != 'D') && (ss[-1] != 'V')) {
|
if ((ss = strstr(line, " Magisk")) && (ss[-1] != 'D') && (ss[-1] != 'V')) {
|
||||||
@ -78,7 +82,7 @@ static void *magisk_log_thread(void *args) {
|
|||||||
}
|
}
|
||||||
vec_destroy(&logs);
|
vec_destroy(&logs);
|
||||||
} else {
|
} else {
|
||||||
vec_push_back(&logs, line);
|
vec_push_back(&logs, strdup(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (have_data)
|
if (have_data)
|
||||||
@ -95,6 +99,8 @@ static void *debug_magisk_log_thread(void *args) {
|
|||||||
if (xpipe2(pipefd, O_CLOEXEC) == -1)
|
if (xpipe2(pipefd, O_CLOEXEC) == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
LOGD("log_monitor: debug log dumper start");
|
||||||
|
|
||||||
// Register our listener
|
// Register our listener
|
||||||
logcat_events[DEBUG_EVENT] = pipefd[1];
|
logcat_events[DEBUG_EVENT] = pipefd[1];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user