fixed not closing ttyread on closing ssh ?
authorChristian Pointner <equinox@realraum.at>
Tue, 12 Jul 2011 23:25:37 +0000 (23:25 +0000)
committerChristian Pointner <equinox@realraum.at>
Tue, 12 Jul 2011 23:25:37 +0000 (23:25 +0000)
dart/start-dart.sh
dart/ttyread.c

index cd30fab..b166866 100755 (executable)
@@ -20,7 +20,6 @@ signal_handler()
 }
 
 stty -echo
-ssh dart killall ttyread >/dev/null 2>&1
 ssh dart ttyread /dev/ttyDart  >$FIFO &
 ./eet $FIFO | ./dart-$mode.pl $* | ../dart-sounds/src/dart-sounds ../dart-sounds/media > /dev/null
 rm -rf $FIFO_D
index beb8856..aad4e7a 100644 (file)
@@ -105,8 +105,23 @@ int main(int argc, char* argv[])
 
   if(setup_tty(fd)) return 3;
 
+  fd_set rfds, efds;
+  
   char buf[100];
   for(;;) {
+    FD_ZERO(&rfds);
+    FD_SET(fd, &rfds);
+    FD_ZERO(&efds);
+    FD_SET(1, &efds);
+
+    int s = select(fd+1, &rfds, NULL, &efds, NULL);
+    if(s < 0) {
+      perror("select()");
+      return s;
+    }
+    if(FD_ISSET(1, &efds)) return 0;
+    if(!FD_ISSET(fd, &rfds)) continue;
+
     ssize_t r = read(fd, buf, sizeof(buf));
     if(r <= 0) {
       perror("read()");