Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit 3ab8e25

Browse files
committed
restart zygote should be reliable
1 parent 3a1231c commit 3ab8e25

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

riru-core/jni/zygote_restart/main.cpp

+20-5
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,28 @@ int main(int argc, char **argv) {
129129
}
130130

131131
if (!is_path_in_maps(pid, CHECK_LIB_NAME)) {
132-
LOGW("no Riru found in " ZYGOTE_NAME ", restart " RESTART_NAME);
133-
134-
// restart zygote_secondary will also restart zygote, see init.zygote64_32.rc
135-
__system_property_set("ctl.restart", const_cast<char *>(RESTART_NAME));
132+
LOGW("no Riru found in %s (pid=%d), restart required", ZYGOTE_NAME, pid);
136133
} else {
137-
LOGI("found Riru in " ZYGOTE_NAME);
134+
LOGI("found Riru in %s (pid=%d)", ZYGOTE_NAME, pid);
135+
return 0;
136+
}
137+
138+
// wait for magisk mount
139+
while (access(CHECK_LIB_NAME, F_OK) != 0) {
140+
LOGV("not mounted, wait 1s");
141+
sleep(1);
138142
}
139143

144+
// check if zygote is restarted by other
145+
if ((pid = get_pid_by_name_and_uid(ZYGOTE_NAME, 0)) != -1
146+
&& is_path_in_maps(pid, CHECK_LIB_NAME)) {
147+
LOGI("found Riru in %s (pid=%d), abort restart", ZYGOTE_NAME, pid);
148+
return 0;
149+
}
150+
151+
LOGI("restart " RESTART_NAME);
152+
// restart zygote_secondary will also restart zygote, see init.zygote64_32.rc
153+
__system_property_set("ctl.restart", const_cast<char *>(RESTART_NAME));
154+
140155
return 0;
141156
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id=riru-core
22
name=Riru - Core
3-
version=v17
4-
versionCode=17
3+
version=v17.1
4+
versionCode=17.1
55
author=Rikka
66
description=Inject zygote process by replace libmemtrack.so, provide interface to other Riru modules.
77
minMagisk=17000

0 commit comments

Comments
 (0)