Changeset 87822ce in mainline for uspace/app/top/top.c


Ignore:
Timestamp:
2021-03-04T19:14:30Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d6c4d40
Parents:
760a392
Message:

Avoid infinite loop when console communication is broken

Need to make sure callers of console_get_event_timeout() can distinguish
between timeout and I/O error. Fix all callers of console_get_event()
and console_get_event_timeout() not to enter infinite loop when console
connection is broken. Also avoid setting of errno variable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/top/top.c

    r760a392 r87822ce  
    583583        data_t data_prev;
    584584        const char *ret = NULL;
     585        errno_t rc;
     586        int c;
    585587
    586588        screen_init();
     
    595597        /* And paint screen until death */
    596598        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 */
    600602                        data_prev = data;
    601603                        if ((ret = read_data(&data)) != NULL) {
     
    608610
    609611                        c = -1;
     612                } else if (rc != EOK) {
     613                        /* Error (e.g. communication with console lost) */
     614                        goto out;
    610615                }
    611616
Note: See TracChangeset for help on using the changeset viewer.