Keep the log catcher alive.

This commit is contained in:
lrh2000 2020-06-23 16:00:00 +08:00 committed by Jim Wu
parent cd8c3b5639
commit 1374ff6745
1 changed files with 15 additions and 2 deletions

View File

@ -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}"
chmod -R 666 "${LOG_PATH}"