summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2014-09-09 21:56:14 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-09-09 21:56:14 +0000
commit500c086a7e93dd485dc98bae5ab8430bc165c301 (patch)
tree8fdd0e0689f5dbd89b0be210734aff7ba518cee2 /cmds
parent75ec33e0e609e3ef074f4230c2227e52bf82ad06 (diff)
parent5ef471c5f986a52c681a29856c38f72127cdf8ac (diff)
downloadframeworks_native-500c086a7e93dd485dc98bae5ab8430bc165c301.tar.gz
frameworks_native-500c086a7e93dd485dc98bae5ab8430bc165c301.tar.bz2
frameworks_native-500c086a7e93dd485dc98bae5ab8430bc165c301.zip
am 5ef471c5: Merge "Use time() instead of clock() for timeouts." into lmp-dev
* commit '5ef471c5f986a52c681a29856c38f72127cdf8ac': Use time() instead of clock() for timeouts.
Diffstat (limited to 'cmds')
-rw-r--r--cmds/dumpstate/utils.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c
index 85c353e10..c8ee75e30 100644
--- a/cmds/dumpstate/utils.c
+++ b/cmds/dumpstate/utils.c
@@ -296,7 +296,7 @@ int dump_file_from_fd(const char *title, const char *path, int fd) {
/* forks a command and waits for it to finish */
int run_command(const char *title, int timeout_seconds, const char *command, ...) {
fflush(stdout);
- clock_t start = clock();
+ time_t start = time(NULL);
pid_t pid = fork();
/* handle error case */
@@ -340,19 +340,19 @@ int run_command(const char *title, int timeout_seconds, const char *command, ...
for (;;) {
int status;
pid_t p = waitpid(pid, &status, WNOHANG);
- float elapsed = (float) (clock() - start) / CLOCKS_PER_SEC;
+ time_t elapsed = time(NULL) - start;
if (p == pid) {
if (WIFSIGNALED(status)) {
printf("*** %s: Killed by signal %d\n", command, WTERMSIG(status));
} else if (WIFEXITED(status) && WEXITSTATUS(status) > 0) {
printf("*** %s: Exit code %d\n", command, WEXITSTATUS(status));
}
- if (title) printf("[%s: %.1fs elapsed]\n\n", command, elapsed);
+ if (title) printf("[%s: %ds elapsed]\n\n", command, (int) elapsed);
return status;
}
if (timeout_seconds && elapsed > timeout_seconds) {
- printf("*** %s: Timed out after %.1fs (killing pid %d)\n", command, elapsed, pid);
+ printf("*** %s: Timed out after %ds (killing pid %d)\n", command, (int) elapsed, pid);
kill(pid, SIGTERM);
return -1;
}