DO NOT MERGE Put a small sleep back in the start of toolbox top.
We saw a divide-by-zero crash that we can't reproduce, and having some delay between scans of /proc should give us better data anyway. Bug: http://b/32478213 Test: manual Change-Id: If57720c57113a966b86022291c5be57127852427
This commit is contained in:
parent
2ed637210e
commit
be6c880398
1 changed files with 7 additions and 0 deletions
|
@ -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 @@ int top_main(int argc, char *argv[]) {
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue