• Artem Bityutskiy's avatar
    tools/power turbostat: fix printing on input · 47936f94
    Artem Bityutskiy authored
    The recent patch that implements table printing on a keypress introduced a
    regression - turbostat prints the table almost continuously if it is run from a
    daemon program.
    
    The problem is also easy to reproduce like this:
    
    echo | turbostat
    
    The reason is that we cannot assume that stdin is always a TTY. It can be many
    things.
    
    This patch adds fixes the problem by limiting the new keypress functionality to
    TTYs only. If stdin is not a TTY, we just sleep for the full interval time.
    
    While on it, clean-up 'do_sleep()' to return no value, as callers do not expect
    that anyway.
    Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
    Signed-off-by: default avatarLen Brown <len.brown@intel.com>
    47936f94
turbostat.c 135 KB