diff --git a/core/jni/core/daemon.c b/core/jni/core/daemon.c index 6b9a9e732..3e5d9c5f9 100644 --- a/core/jni/core/daemon.c +++ b/core/jni/core/daemon.c @@ -20,7 +20,6 @@ #include "daemon.h" #include "resetprop.h" -pthread_t sepol_patch; int is_daemon_init = 0, seperate_vendor = 0; static void *request_handler(void *args) { @@ -232,6 +231,9 @@ void start_daemon() { exit(1); xlisten(fd, 10); + // Start the log monitor + monitor_logs(); + if ((is_daemon_init = access(MAGISKTMP, F_OK) == 0)) { // Restart stuffs if the daemon is restarted exec_command_sync("logcat", "-b", "all", "-c", NULL); @@ -241,9 +243,6 @@ void start_daemon() { daemon_init(); } - // Start the log monitor - monitor_logs(); - LOGI("Magisk v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ") daemon started\n"); // Change process name diff --git a/core/jni/core/log_monitor.c b/core/jni/core/log_monitor.c index 44d7f9ae7..2b44f3e02 100644 --- a/core/jni/core/log_monitor.c +++ b/core/jni/core/log_monitor.c @@ -50,7 +50,7 @@ static void *logger_thread(void *args) { static void *magisk_log_thread(void *args) { int have_data = 0; - // Temp buffer for logs before we have data access + // Buffer logs before we have data access struct vector logs; vec_init(&logs); @@ -70,8 +70,7 @@ static void *magisk_log_thread(void *args) { if (!have_data) { if ((have_data = check_data())) { // Dump buffered logs to file - if (!is_daemon_init) - rename(LOGFILE, LASTLOG); + rename(LOGFILE, LASTLOG); log = xfopen(LOGFILE, "a"); setbuf(log, NULL); char *tmp; diff --git a/core/jni/include/daemon.h b/core/jni/include/daemon.h index 255b02f40..1e7217e50 100644 --- a/core/jni/include/daemon.h +++ b/core/jni/include/daemon.h @@ -7,7 +7,6 @@ #include #include -extern pthread_t sepol_patch; extern int is_daemon_init, seperate_vendor; // Commands require connecting to daemon