intel_cpus::get_msr calls exit if pread failed, leaving terminal in incorrect state (after init_display call).
Patch fixes terminal state and outputs human readable error, e.g. "pread cpu0 0xe8 : Bad file descriptor" (`bad file descriptor' due to missing open call check.) Signed-off-by: Sergey Senozhatsky <[email protected]> --- cpu/intel_cpus.cpp | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cpu/intel_cpus.cpp b/cpu/intel_cpus.cpp index f27853d..44a178a 100644 --- a/cpu/intel_cpus.cpp +++ b/cpu/intel_cpus.cpp @@ -33,9 +33,11 @@ #include <fcntl.h> #include <sys/time.h> #include <string.h> +#include <errno.h> #include "../lib.h" #include "../parameters/parameters.h" +#include "../display.h" static int is_turbo(uint64_t freq, uint64_t max, uint64_t maxmo) { @@ -55,13 +57,15 @@ static uint64_t get_msr(int cpu, uint64_t offset) int fd; char msr_path[256]; - fd =sprintf(msr_path, "/dev/cpu/%d/msr", cpu); + fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu); fd = open(msr_path, O_RDONLY); retval = pread(fd, &msr, sizeof msr, offset); if (retval != sizeof msr) { - fprintf(stderr, "pread cpu%d 0x%llx \n", cpu, (unsigned long long)offset); - _exit(-2); + reset_display(); + fprintf(stderr, "pread cpu%d 0x%llx : ", cpu, (unsigned long long)offset); + fprintf(stderr, "%s\n", strerror(errno)); + exit(-2); } close(fd); return msr; _______________________________________________ Discuss mailing list [email protected] http://lists.lesswatts.org/listinfo/discuss
