Added a test to check we do have a tty (and not a pipe in).
authorFrancois Fleuret <francois@fleuret.org>
Tue, 17 Mar 2009 19:31:00 +0000 (20:31 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Tue, 17 Mar 2009 19:31:00 +0000 (20:31 +0100)
selector.cc

index 9dafd4d..cfb583e 100644 (file)
@@ -388,6 +388,12 @@ void update_screen(int *current_line, int *temporary_line, int motion,
 //////////////////////////////////////////////////////////////////////
 
 int main(int argc, char **argv) {
+
+  if(!ttyname(STDIN_FILENO)) {
+    cerr << "Error: the standard input is not a tty." << endl;
+    exit(1);
+  }
+
   char buffer[buffer_size];
   int color_fg_modeline, color_bg_modeline;
   int color_fg_highlight, color_bg_highlight;