tag 488973 + patch
tag 488973 - unreproducible
thanks

Hi,

I can reproduce this bug when running powertop under gnome-terminal.

The problem is that powertop exits when it receives a SIGWINCH. It thinks that the user has pressed a key, but gets EOF. The attached patch fixes it. I have sent it upstream as well.

--
Pelle
--- powertop-1.11/powertop.c.orig	2009-12-18 14:28:04.000000000 +0100
+++ powertop-1.11/powertop.c	2009-12-18 14:23:38.000000000 +0100
@@ -36,6 +36,7 @@
 #include <locale.h>
 #include <time.h>
 #include <sys/stat.h>
+#include <errno.h>
 
 #include "powertop.h"
 
@@ -867,8 +868,12 @@
 
 		key = select(1, &rfds, NULL, NULL, &tv);
 
-		if (key && tv.tv_sec) ticktime = ticktime - tv.tv_sec - tv.tv_usec/1000000.0;
+		if (key > 0 && tv.tv_sec) ticktime = ticktime - tv.tv_sec - tv.tv_usec/1000000.0;
 
+		if (key == -1 && errno != EINTR) {
+			perror("select");
+			exit(EXIT_FAILURE);
+		}
 
 		stop_timerstats();
 		clear_lines();
@@ -1035,7 +1040,7 @@
 		else
 			ticktime = 45;
 
-		if (key) {
+		if (key > 0) {
 			char keychar;
 			int keystroke = fgetc(stdin);
 			if (keystroke == EOF)

Reply via email to