From 201e32d4c418d6042398b8d96236df7752d82c16 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 8 Jun 2017 19:15:51 +0800 Subject: [PATCH] Fix daemon crashes in encrypted /data --- jni/daemon/bootstages.c | 12 ++++++++++++ jni/daemon/log_monitor.c | 11 ----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/jni/daemon/bootstages.c b/jni/daemon/bootstages.c index 5c2391d3a..5de9fb8a7 100644 --- a/jni/daemon/bootstages.c +++ b/jni/daemon/bootstages.c @@ -21,6 +21,10 @@ static char *buf, *buf2; static struct vector module_list; +#ifdef DEBUG +static int debug_log_pid, debug_log_fd; +#endif + /****************** * Node structure * ******************/ @@ -485,12 +489,20 @@ unblock: void post_fs_data(int client) { // Error handler err_handler = unblock_boot_process; + // ack write_int(client, 0); close(client); if (!check_data()) goto unblock; +#ifdef DEBUG + // Start debug logs in new process + debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644); + char *const command[] = { "logcat", "-v", "brief", NULL }; + debug_log_pid = run_command(0, &debug_log_fd, "/system/bin/logcat", command); +#endif + LOGI("** post-fs-data mode running\n"); // uninstaller diff --git a/jni/daemon/log_monitor.c b/jni/daemon/log_monitor.c index e7124c2f6..16621a6ef 100644 --- a/jni/daemon/log_monitor.c +++ b/jni/daemon/log_monitor.c @@ -15,10 +15,6 @@ #include "utils.h" #include "daemon.h" -#ifdef DEBUG -int debug_log_pid, debug_log_fd; -#endif - static void *logger_thread(void *args) { // Setup error handler err_handler = exit_thread; @@ -47,11 +43,4 @@ void monitor_logs() { pthread_t thread; xpthread_create(&thread, NULL, logger_thread, NULL); pthread_detach(thread); - -#ifdef DEBUG - // Start debug logs in new process - debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644); - char *const command[] = { "logcat", "-v", "brief", NULL }; - debug_log_pid = run_command(0, &debug_log_fd, "/system/bin/logcat", command); -#endif }