Removed/Fixed TODO DRY
authorNiklas Fiekas <niklas.fiekas@googlemail.com>
Fri, 24 Dec 2010 23:40:48 +0000 (00:40 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Mon, 4 Jul 2011 19:15:00 +0000 (21:15 +0200)
src/node_stdio.cc

index f744e3f..f654d2b 100644 (file)
@@ -198,15 +198,15 @@ static Handle<Value> OpenStdin(const Arguments& args) {
   if (isatty(STDIN_FILENO)) {
     // XXX selecting on tty fds wont work in windows.
     // Must ALWAYS make a coupling on shitty platforms.
+    int r = -1;
+
     stdin_flags = fcntl(STDIN_FILENO, F_GETFL, 0);
-    if (stdin_flags == -1) {
-      // TODO DRY
-      return ThrowException(Exception::Error(String::New("fcntl error!")));
+
+    if (stdin_flags != -1) {
+      r = fcntl(STDIN_FILENO, F_SETFL, stdin_flags | O_NONBLOCK);
     }
 
-    int r = fcntl(STDIN_FILENO, F_SETFL, stdin_flags | O_NONBLOCK);
     if (r == -1) {
-      // TODO DRY
       return ThrowException(Exception::Error(String::New("fcntl error!")));
     }
   }