projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
When writing session data to stdout or stderr, switch the relevant file
[u/mdw/putty]
/
unix
/
uxplink.c
diff --git
a/unix/uxplink.c
b/unix/uxplink.c
index
a1dac9a
..
9d5f001
100644
(file)
--- 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;
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);
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);
ret = write(fd, senddata, sendlen);
+ if (fl != -1 && !(fl & O_NONBLOCK))
+ fcntl(fd, F_SETFL, fl);
if (ret > 0)
bufchain_consume(chain, ret);
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);
}
perror(is_stderr ? "stderr: write" : "stdout: write");
exit(1);
}