Changeset 87822ce in mainline for uspace/app/top
- Timestamp:
- 2021-03-04T19:14:30Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d6c4d40
- Parents:
- 760a392
- Location:
- uspace/app/top
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/top/screen.c
r760a392 r87822ce 534 534 /** Get char with timeout 535 535 * 536 * @param sec Timeout in seconds 537 * @param rch Place to store character on success 538 * @return EOK on success, ETIMEOUT on time out, EIO on other error 536 539 */ 537 int tgetchar(sec_t sec) 538 { 540 errno_t tgetchar(sec_t sec, int *rch) 541 { 542 errno_t rc; 543 539 544 /* 540 545 * Reset timeleft whenever it is not positive. … … 548 553 * update timeleft so that the next call to tgetchar() 549 554 * will not wait as long. If there is no input, 550 * make timeleft zero and return -1.555 * make timeleft zero and return ETIMEOUT. 551 556 */ 552 557 … … 557 562 558 563 warning_timeleft -= timeleft; 559 if (!console_get_event_timeout(console, &event, &timeleft)) { 564 rc = console_get_event_timeout(console, &event, &timeleft); 565 if (rc == ETIMEOUT) { 560 566 timeleft = 0; 561 return -1; 562 } 567 return ETIMEOUT; 568 } 569 570 if (rc != EOK) 571 return EIO; 572 563 573 warning_timeleft += timeleft; 564 574 … … 567 577 } 568 578 569 return (int) c; 579 *rch = (int) c; 580 return EOK; 570 581 } 571 582 -
uspace/app/top/screen.h
r760a392 r87822ce 35 35 #define TOP_SCREEN_H_ 36 36 37 #include <errno.h> 37 38 #include <io/console.h> 38 39 #include <io/verify.h> … … 47 48 _HELENOS_PRINTF_ATTRIBUTE(1, 2); 48 49 49 extern int tgetchar(sec_t);50 extern errno_t tgetchar(sec_t, int *); 50 51 51 52 #endif -
uspace/app/top/top.c
r760a392 r87822ce 583 583 data_t data_prev; 584 584 const char *ret = NULL; 585 errno_t rc; 586 int c; 585 587 586 588 screen_init(); … … 595 597 /* And paint screen until death */ 596 598 while (true) { 597 int c = tgetchar(UPDATE_INTERVAL);598 599 if ( c < 0) { /* timeout */599 rc = tgetchar(UPDATE_INTERVAL, &c); 600 601 if (rc == ETIMEOUT) { /* timeout */ 600 602 data_prev = data; 601 603 if ((ret = read_data(&data)) != NULL) { … … 608 610 609 611 c = -1; 612 } else if (rc != EOK) { 613 /* Error (e.g. communication with console lost) */ 614 goto out; 610 615 } 611 616
Note:
See TracChangeset
for help on using the changeset viewer.
