aboutsummaryrefslogtreecommitdiff
path: root/src/systemcmds/top/top.c
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-08-28 08:14:13 +0200
committerLorenz Meier <lm@inf.ethz.ch>2013-08-28 08:14:13 +0200
commit5fe3c49ba0e7e3f64f5b6c9b64ced675c01b14fe (patch)
tree5f024477d370d92edacead7412f60f6757cbf082 /src/systemcmds/top/top.c
parente44d134c6c64535f67e26f9633206aba50a10613 (diff)
parent66c61fbe96e11ee7099431a8370d84f862543810 (diff)
downloadpx4-firmware-5fe3c49ba0e7e3f64f5b6c9b64ced675c01b14fe.tar.gz
px4-firmware-5fe3c49ba0e7e3f64f5b6c9b64ced675c01b14fe.tar.bz2
px4-firmware-5fe3c49ba0e7e3f64f5b6c9b64ced675c01b14fe.zip
Merged multirotor branch
Diffstat (limited to 'src/systemcmds/top/top.c')
-rw-r--r--src/systemcmds/top/top.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/systemcmds/top/top.c b/src/systemcmds/top/top.c
index 0d064a05e..1ca3fc928 100644
--- a/src/systemcmds/top/top.c
+++ b/src/systemcmds/top/top.c
@@ -107,9 +107,6 @@ top_main(void)
float interval_time_ms_inv = 0.f;
- /* Open console directly to grab CTRL-C signal */
- int console = open("/dev/console", O_NONBLOCK | O_RDONLY | O_NOCTTY);
-
/* clear screen */
printf("\033[2J");
@@ -256,17 +253,24 @@ top_main(void)
interval_start_time = new_time;
/* Sleep 200 ms waiting for user input five times ~ 1s */
- /* XXX use poll ... */
for (int k = 0; k < 5; k++) {
char c;
- if (read(console, &c, 1) == 1) {
+ struct pollfd fds;
+ int ret;
+ fds.fd = 0; /* stdin */
+ fds.events = POLLIN;
+ ret = poll(&fds, 1, 0);
+
+ if (ret > 0) {
+
+ read(0, &c, 1);
+
switch (c) {
case 0x03: // ctrl-c
case 0x1b: // esc
case 'c':
case 'q':
- close(console);
return OK;
/* not reached */
}
@@ -278,7 +282,5 @@ top_main(void)
new_time = hrt_absolute_time();
}
- close(console);
-
return OK;
}