diff --git a/adb/services.c b/adb/services.c
index f0d587817e40fbc91e476757965937cf92139738..951048e58471009b469df8b15a8d24c0371f9836 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -144,7 +144,11 @@ void reboot_service(int fd, void *arg)
if (ret < 0) {
snprintf(buf, sizeof(buf), "reboot failed: %d\n", ret);
writex(fd, buf, strlen(buf));
+ goto cleanup;
}
+ // Don't return early. Give the reboot command time to take effect
+ // to avoid messing up scripts which do "adb reboot && adb wait-for-device"
+ while(1) { pause(); }
cleanup:
free(arg);
adb_close(fd);
diff --git a/reboot/reboot.c b/reboot/reboot.c
index 0e5170d4258d0cd9902c8f67d93770a35d94b6cc..d9a422764d36cf186e6c60de825da106bf2a0ea2 100644
--- a/reboot/reboot.c
+++ b/reboot/reboot.c
@@ -68,6 +68,11 @@ int main(int argc, char *argv[])
perror("reboot");
exit(EXIT_FAILURE);
}
+
+ // Don't return early. Give the reboot command time to take effect
+ // to avoid messing up scripts which do "adb shell reboot && adb wait-for-device"
+ while(1) { pause(); }
+
fprintf(stderr, "Done\n");
return 0;
}