Improve daemon startup and log management
This commit is contained in:
parent
0327fd9710
commit
bb7099376b
@ -140,8 +140,9 @@ void start_daemon() {
|
|||||||
xdup2(fd, STDERR_FILENO);
|
xdup2(fd, STDERR_FILENO);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
if ((is_restart = check_data())) {
|
if ((is_restart = access(UNBLOCKFILE, F_OK) == 0)) {
|
||||||
// Restart many stuffs
|
// Restart stuffs if the daemon is restarted
|
||||||
|
exec_command_sync("logcat", "-b", "all", "-c", NULL);
|
||||||
auto_start_magiskhide();
|
auto_start_magiskhide();
|
||||||
start_debug_log();
|
start_debug_log();
|
||||||
}
|
}
|
||||||
@ -174,6 +175,9 @@ void start_daemon() {
|
|||||||
// Unlock all blocks for rw
|
// Unlock all blocks for rw
|
||||||
unlock_blocks();
|
unlock_blocks();
|
||||||
|
|
||||||
|
// Notifiy init the daemon is started
|
||||||
|
close(open(UNBLOCKFILE, O_RDONLY));
|
||||||
|
|
||||||
// Loop forever to listen for requests
|
// Loop forever to listen for requests
|
||||||
while(1) {
|
while(1) {
|
||||||
int *client = xmalloc(sizeof(int));
|
int *client = xmalloc(sizeof(int));
|
||||||
|
@ -29,10 +29,8 @@ static void *logger_thread(void *args) {
|
|||||||
char line[4096];
|
char line[4096];
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// Clear buffer
|
|
||||||
exec_command_sync("logcat", "-b", "all", "-c", NULL);
|
|
||||||
// Start logcat
|
// Start logcat
|
||||||
log_pid = exec_command(0, &log_fd, NULL, "logcat", "-b", "events", "-b", "default", "-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);
|
||||||
while (fdgets(line, sizeof(line), log_fd)) {
|
while (fdgets(line, sizeof(line), log_fd)) {
|
||||||
for (int i = 0; i < (sizeof(logcat_events) / sizeof(int)); ++i) {
|
for (int i = 0; i < (sizeof(logcat_events) / sizeof(int)); ++i) {
|
||||||
if (logcat_events[i] > 0) {
|
if (logcat_events[i] > 0) {
|
||||||
@ -43,6 +41,8 @@ static void *logger_thread(void *args) {
|
|||||||
if (kill(log_pid, 0))
|
if (kill(log_pid, 0))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Clear buffer if restart required
|
||||||
|
exec_command_sync("logcat", "-b", "all", "-c", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should never be here, but well...
|
// Should never be here, but well...
|
||||||
@ -133,7 +133,7 @@ void start_debug_full_log() {
|
|||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
// Log everything initially
|
// Log everything initially
|
||||||
debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644);
|
debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644);
|
||||||
debug_log_pid = exec_command(0, &debug_log_fd, NULL, "logcat", NULL);
|
debug_log_pid = exec_command(0, &debug_log_fd, NULL, "logcat", "-v", "threadtime", NULL);
|
||||||
close(debug_log_fd);
|
close(debug_log_fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
on post-fs
|
on post-fs
|
||||||
start logd
|
start logd
|
||||||
start magisk_daemon
|
start magisk_daemon
|
||||||
wait /dev/.magisk.unblock 1
|
|
||||||
start magisk_pfs
|
|
||||||
wait /dev/.magisk.unblock 5
|
wait /dev/.magisk.unblock 5
|
||||||
|
rm /dev/.magisk.unblock
|
||||||
|
start magisk_pfs
|
||||||
|
wait /dev/.magisk.unblock 10
|
||||||
|
|
||||||
on post-fs-data
|
on post-fs-data
|
||||||
rm /dev/.magisk.unblock
|
|
||||||
load_persist_props
|
load_persist_props
|
||||||
|
rm /dev/.magisk.unblock
|
||||||
start magisk_pfsd
|
start magisk_pfsd
|
||||||
wait /dev/.magisk.unblock 10
|
wait /dev/.magisk.unblock 10
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user