From: Christian Pointner Date: Tue, 12 Jul 2011 23:25:37 +0000 (+0000) Subject: fixed not closing ttyread on closing ssh ? X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=ed56aa9dd776a4eb9928895f84a6f8a3276eba84;p=svn42.git fixed not closing ttyread on closing ssh ? --- diff --git a/dart/start-dart.sh b/dart/start-dart.sh index cd30fab..b166866 100755 --- a/dart/start-dart.sh +++ b/dart/start-dart.sh @@ -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 diff --git a/dart/ttyread.c b/dart/ttyread.c index beb8856..aad4e7a 100644 --- a/dart/ttyread.c +++ b/dart/ttyread.c @@ -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()");