Hi,
I think powertop should check for tty in interactive
mode and abort if there is none (like top does),
e.g. something like this:
# powertop < /dev/null
PowerTOP 1.13 (C) 2007 - 2010 Intel Corporation
No valid input tty for interactive mode, aborting.
Patch for git head attached
Jaroslav
--- powertop.c.old 2010-12-06 11:32:53.879419977 +0100
+++ powertop.c 2010-12-06 11:32:55.919868911 +0100
@@ -23,6 +23,7 @@
*/
#include <getopt.h>
+#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -898,6 +899,7 @@
FILE *file = NULL;
uint64_t cur_usage[MAX_NUM_CSTATES], cur_duration[MAX_NUM_CSTATES];
double wakeups_per_second = 0;
+ struct termios tmp_tty;
setlocale (LC_ALL, "");
bindtextdomain ("powertop", "/usr/share/locale");
@@ -968,6 +970,12 @@
printf("PowerTOP " VERSION " (C) 2007 - 2010 Intel Corporation \n\n");
if (geteuid() != 0)
printf(_("PowerTOP needs to be run as root to collect enough information\n"));
+
+ if (!dump && tcgetattr(STDIN_FILENO, &tmp_tty) == -1) {
+ printf(_("No valid input tty for interactive mode, aborting.\n"));
+ exit(1);
+ }
+
printf(_("Collecting data for %i seconds \n"), (int)ticktime);
printf("\n\n");
print_intel_cstates();
_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power