X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/d719927eb175a73b13a7015498e9757010344bf5..f9520103d3b3a1a36fdb30a46aa4f6c1cd3f1c9e:/unix/uxplink.c diff --git a/unix/uxplink.c b/unix/uxplink.c index 0d896225..898f27c3 100644 --- a/unix/uxplink.c +++ b/unix/uxplink.c @@ -63,6 +63,22 @@ void modalfatalbox(char *p, ...) } cleanup_exit(1); } +void nonfatal(char *p, ...) +{ + struct termios cf; + va_list ap; + premsg(&cf); + fprintf(stderr, "ERROR: "); + va_start(ap, p); + vfprintf(stderr, p, ap); + va_end(ap); + fputc('\n', stderr); + postmsg(&cf); + if (logctx) { + log_free(logctx); + logctx = NULL; + } +} void connection_fatal(void *frontend, char *p, ...) { struct termios cf; @@ -380,20 +396,18 @@ int 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, fl; + int sendlen, ret; if (bufchain_size(chain) > 0) { - fl = fcntl(fd, F_GETFL); - if (fl != -1 && !(fl & O_NONBLOCK)) - fcntl(fd, F_SETFL, fl | O_NONBLOCK); + int prev_nonblock = nonblock(fd); do { bufchain_prefix(chain, &senddata, &sendlen); ret = write(fd, senddata, sendlen); if (ret > 0) bufchain_consume(chain, ret); } while (ret == sendlen && bufchain_size(chain) != 0); - if (fl != -1 && !(fl & O_NONBLOCK)) - fcntl(fd, F_SETFL, fl); + if (!prev_nonblock) + no_nonblock(fd); if (ret < 0 && errno != EAGAIN) { perror(is_stderr ? "stderr: write" : "stdout: write"); exit(1); @@ -654,8 +668,11 @@ int main(int argc, char **argv) } else if (!strcmp(p, "-s")) { /* Save status to write to conf later. */ use_subsystem = 1; - } else if (!strcmp(p, "-V")) { + } else if (!strcmp(p, "-V") || !strcmp(p, "--version")) { version(); + } else if (!strcmp(p, "--help")) { + usage(); + exit(0); } else if (!strcmp(p, "-pgpfp")) { pgp_fingerprints(); exit(1);