From 1374ff6745d186890d3fae3279bf9d28325f4990 Mon Sep 17 00:00:00 2001 From: lrh2000 Date: Tue, 23 Jun 2020 16:00:00 +0800 Subject: [PATCH] Keep the log catcher alive. --- edxp-core/template_override/post-fs-data.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/edxp-core/template_override/post-fs-data.sh b/edxp-core/template_override/post-fs-data.sh index e3b1b2ac..84deebdf 100644 --- a/edxp-core/template_override/post-fs-data.sh +++ b/edxp-core/template_override/post-fs-data.sh @@ -85,6 +85,19 @@ if [[ -f ${DISABLE_VERBOSE_LOG_FILE} ]]; then LOG_VERBOSE=false fi +# If logcat client is kicked out by klogd server, we'll restart it. +# However, if it is killed manually or by EdXposed Manager, we'll exit. +# Refer to https://github.com/ElderDrivers/EdXposed/pull/575 for more information. +loop_logcat() { + while true + do + logcat $* + if [[ $? -ne 1 ]]; then + break + fi + done +} + start_log_cather () { LOG_FILE_NAME=$1 LOG_TAG_FILTERS=$2 @@ -126,7 +139,7 @@ start_log_cather () { echo "Riru version: ${RIRU_VERSION} (${RIRU_VERCODE})">>${LOG_FILE} echo "Riru api: ${RIRU_APICODE}">>${LOG_FILE} echo "Magisk: ${MAGISK_VERSION%:*} (${MAGISK_VERCODE})">>${LOG_FILE} - logcat -f ${LOG_FILE} *:S ${LOG_TAG_FILTERS} & + loop_logcat -f ${LOG_FILE} *:S ${LOG_TAG_FILTERS} & LOG_PID=$! echo "${LOG_PID}">"${LOG_PATH}/${LOG_FILE_NAME}.pid" } @@ -167,4 +180,4 @@ fi chcon -R u:object_r:system_file:s0 "${MODDIR}" chcon -R ${PATH_CONTEXT} "${LOG_PATH}" chown -R ${PATH_OWNER} "${LOG_PATH}" -chmod -R 666 "${LOG_PATH}" \ No newline at end of file +chmod -R 666 "${LOG_PATH}"