mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
test(semaphores): count only reaped children, only futex waits as emulator stalls
This commit is contained in:
1 parent
63f5ac5b5e
commit
056be5f3a1
1 file changed
+5
-2
@@ -76,7 +76,8 @@ static int stuck_in_emulator(pid_t pid) {
|
||||
FILE *f = fopen(path, "r");
|
||||
int got = f && fscanf(f, "%lu %lx", &nr, &addr) == 2;
|
||||
if (f) fclose(f);
|
||||
if (!got) return 0;
|
||||
// the host's futex call: 202 on x86-64, where qemu-user runs, 98 on aarch64
|
||||
if (!got || (nr != 202 && nr != 98)) return 0;
|
||||
f = fopen("/proc/self/maps", "r");
|
||||
if (!f) return 0;
|
||||
int guest = 0;
|
||||
@@ -109,13 +110,15 @@ int main(int argc, char **argv) {
|
||||
_exit(sem == SEM_FAILED || sem_close(sem) != 0);
|
||||
}
|
||||
int status = 0, stalled = 0;
|
||||
for (int waited = 0; waitpid(pid, &status, WNOHANG) == 0; waited++) {
|
||||
pid_t r;
|
||||
for (int waited = 0; (r = waitpid(pid, &status, WNOHANG)) == 0; waited++) {
|
||||
if (waited == 1000) { // 10 s
|
||||
stalled = stuck_in_emulator(pid);
|
||||
kill(pid, SIGKILL);
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
if (r != pid) continue;
|
||||
if (stalled) emulator++;
|
||||
else if (WIFEXITED(status) && WEXITSTATUS(status) == 0) finished++;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user