Merge "adb: actually fix the windows build." into klp-dev am: da66b9100a am: 0b4bd3feea am: 55d871c401 am: 8027acd140 am: 7e21e1efeb am: fa961006fd am: 50dcfdf43a am: f69ff66c5f am: 238a980143 am: ffcd14a9b9 am: 7149e3e72a am: 058bae82ed am: 5751e3335d
am: 79517d4f9f
Change-Id: I78fe778bb69d3be0551e062602a3517ff0b3220a
diff --git a/toolbox/top.c b/toolbox/top.c
index 6fda132..e70ea31 100644
--- a/toolbox/top.c
+++ b/toolbox/top.c
@@ -31,6 +31,7 @@
#include <ctype.h>
#include <dirent.h>
+#include <errno.h>
#include <grp.h>
#include <inttypes.h>
#include <pwd.h>
@@ -38,6 +39,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <time.h>
#include <unistd.h>
#include <cutils/sched_policy.h>
@@ -180,6 +182,11 @@
new_procs = old_procs = NULL;
read_procs();
+
+ // Pause 250ms to get better data and avoid divide by zero later (http://b/32478213).
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 250000000 };
+ TEMP_FAILURE_RETRY(nanosleep(&ts, &ts));
+
while ((iterations == -1) || (iterations-- > 0)) {
old_procs = new_procs;
num_old_procs = num_new_procs;