X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/f7397dc65858f1105d78930fa530c9d829a03336..61f62bb301d0b6d49d1fea71513eb051a901e1b1:/unix/uxplink.c diff --git a/unix/uxplink.c b/unix/uxplink.c index a1dac9ad..9867df2e 100644 --- a/unix/uxplink.c +++ b/unix/uxplink.c @@ -389,16 +389,21 @@ void try_output(int is_stderr) bufchain *chain = (is_stderr ? &stderr_data : &stdout_data); int fd = (is_stderr ? STDERR_FILENO : STDOUT_FILENO); void *senddata; - int sendlen, ret; + int sendlen, ret, fl; if (bufchain_size(chain) == 0) return; bufchain_prefix(chain, &senddata, &sendlen); + fl = fcntl(fd, F_GETFL); + if (fl != -1 && !(fl & O_NONBLOCK)) + fcntl(fd, F_SETFL, fl | O_NONBLOCK); ret = write(fd, senddata, sendlen); + if (fl != -1 && !(fl & O_NONBLOCK)) + fcntl(fd, F_SETFL, fl); if (ret > 0) bufchain_consume(chain, ret); - else if (ret < 0) { + else if (ret < 0 && errno != EAGAIN) { perror(is_stderr ? "stderr: write" : "stdout: write"); exit(1); } @@ -868,6 +873,14 @@ int main(int argc, char **argv) uxsel_init(); /* + * Unix Plink doesn't provide any way to add forwardings after the + * connection is set up, so if there are none now, we can safely set + * the "simple" flag. + */ + if (cfg.protocol == PROT_SSH && !cfg.x11_forward && !cfg.agentfwd && + cfg.portfwd[0] == '\0' && cfg.portfwd[1] == '\0') + cfg.ssh_simple = TRUE; + /* * Start up the connection. */ logctx = log_init(NULL, &cfg);