Improve write error handling and reporting

parent e33391b7
......@@ -527,8 +527,9 @@ main(int argc, char *argv[], char * const envp[])
ibufr = ibuf + (isz - tryisz);
isz = tryisz;
if (osz > 0) {
(void) vmwrite(STDOUT_FILENO, obuf, osz);
if (osz > 0 && vmwrite(STDOUT_FILENO, obuf, osz) < 0) {
cleanup();
pexit("write stdout");
}
thr = pthread_self();
......@@ -541,11 +542,13 @@ main(int argc, char *argv[], char * const envp[])
if (writefd >= 0) {
blockf(writefd);
if (isz > 0)
(void) vmwrite(writefd, ibufr, isz);
if (isz > 0 && vmwrite(writefd, ibufr, isz) < 0) {
perror("write bufffer to trycmd");
} else {
spl_in[0] = STDIN_FILENO;
spl_in[1] = writefd;
(void) splicer(spl_in);
}
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