Go back to reseting io_buffer offset and length (and now also the
EOF handling) in the loop we do the FD_SET, not after we drain the buffer after write() since we don't know what order reads and writes will occur in.
This commit is contained in:
18
src/script.c
18
src/script.c
@@ -674,6 +674,16 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
|
||||
|
||||
FD_SET(sv[0], fdsr);
|
||||
for (iob = iobufs; iob; iob = iob->next) {
|
||||
if (iob->rfd == -1 && iob->wfd == -1)
|
||||
continue;
|
||||
if (iob->off == iob->len) {
|
||||
iob->off = iob->len = 0;
|
||||
/* Forward the EOF from reader to writer. */
|
||||
if (iob->rfd == -1) {
|
||||
close(iob->wfd);
|
||||
iob->wfd = -1;
|
||||
}
|
||||
}
|
||||
/* Don't read/write /dev/tty if we are not in the foreground. */
|
||||
if (iob->rfd != -1 &&
|
||||
(ttymode == TERM_RAW || iob->rfd != script_fds[SFD_USERTTY])) {
|
||||
@@ -786,14 +796,6 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
|
||||
} else {
|
||||
iob->off += n;
|
||||
}
|
||||
if (iob->off == iob->len) {
|
||||
iob->off = iob->len = 0;
|
||||
/* Forward the EOF from reader to writer. */
|
||||
if (iob->rfd == -1) {
|
||||
close(iob->wfd);
|
||||
iob->wfd = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user