Improve write error handling and reporting

parent e33391b7
...@@ -527,8 +527,9 @@ main(int argc, char *argv[], char * const envp[]) ...@@ -527,8 +527,9 @@ main(int argc, char *argv[], char * const envp[])
ibufr = ibuf + (isz - tryisz); ibufr = ibuf + (isz - tryisz);
isz = tryisz; isz = tryisz;
if (osz > 0) { if (osz > 0 && vmwrite(STDOUT_FILENO, obuf, osz) < 0) {
(void) vmwrite(STDOUT_FILENO, obuf, osz); cleanup();
pexit("write stdout");
} }
thr = pthread_self(); thr = pthread_self();
...@@ -541,11 +542,13 @@ main(int argc, char *argv[], char * const envp[]) ...@@ -541,11 +542,13 @@ main(int argc, char *argv[], char * const envp[])
if (writefd >= 0) { if (writefd >= 0) {
blockf(writefd); blockf(writefd);
if (isz > 0) if (isz > 0 && vmwrite(writefd, ibufr, isz) < 0) {
(void) vmwrite(writefd, ibufr, isz); perror("write bufffer to trycmd");
spl_in[0] = STDIN_FILENO; } else {
spl_in[1] = writefd; spl_in[0] = STDIN_FILENO;
(void) splicer(spl_in); spl_in[1] = writefd;
(void) splicer(spl_in);
}
closef(writefd); closef(writefd);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment