My changes in r7738 (O_NONBLOCK for Unix Plink) were half-arsed, and
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Mon, 24 Sep 2007 21:43:48 +0000 (21:43 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Mon, 24 Sep 2007 21:43:48 +0000 (21:43 +0000)
completely broke interactive logins.  The problem, or at least one of the
problems, was that in interactive use stdin, stdout, and stderr tend to be
the same file, so setting O_NONBLOCK on the latter two also sets it on the
former.  Thus, we need to cope with all of them being non-blocking.

git-svn-id: svn://svn.tartarus.org/sgt/putty@7742 cda61777-01e9-0310-a592-d414129be87e

unix/uxplink.c

index db88199..13369b1 100644 (file)
@@ -385,7 +385,7 @@ void try_output(int is_stderr)
     ret = write(fd, senddata, sendlen);
     if (ret > 0)
        bufchain_consume(chain, ret);
-    else if (ret < 0 && errno != EWOULDBLOCK) {
+    else if (ret < 0) {
        perror(is_stderr ? "stderr: write" : "stdout: write");
        exit(1);
     }
@@ -883,23 +883,6 @@ int main(int argc, char **argv)
     local_tty = (tcgetattr(STDIN_FILENO, &orig_termios) == 0);
     atexit(cleanup_termios);
     ldisc_update(NULL, 1, 1);
-
-    {
-       int fl;
-       /*
-        * Make sure that stdout/err are non-blocking.
-        */
-       if ((fl = fcntl(STDOUT_FILENO, F_GETFL)) == -1 ||
-           fcntl(STDOUT_FILENO, F_SETFL, fl | O_NONBLOCK) == -1) {
-           perror("stdout");
-           exit(1);
-       }
-       if ((fl = fcntl(STDERR_FILENO, F_GETFL)) == -1 ||
-           fcntl(STDERR_FILENO, F_SETFL, fl | O_NONBLOCK) == -1) {
-           perror("stderr");
-           exit(1);
-       }
-    }
     sending = FALSE;
     now = GETTICKCOUNT();