working on issue with pty redirection, not easily reproducible
parent
e03a7e67b8
commit
60a9f2bad2
|
@ -216,7 +216,7 @@ int exec_pty(
|
||||||
!(watched_fds[2].events & POLLIN)) {
|
!(watched_fds[2].events & POLLIN)) {
|
||||||
break_out = true;
|
break_out = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_files_readable == -1) {
|
if (num_files_readable == -1) {
|
||||||
// error occurred in poll()
|
// error occurred in poll()
|
||||||
safe_perror("poll", &ttyOrig );
|
safe_perror("poll", &ttyOrig );
|
||||||
|
@ -268,17 +268,28 @@ int exec_pty(
|
||||||
//break_out = true;
|
//break_out = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// if (watched_fds[this_fd].revents & POLLHUP) {
|
||||||
|
// // this pipe has hung up
|
||||||
|
// close(watched_fds[this_fd].fd);
|
||||||
|
// break_out = true;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
if (watched_fds[this_fd].revents & POLLHUP) {
|
if (watched_fds[this_fd].revents & POLLHUP) {
|
||||||
// this pipe has hung up
|
// this pipe has hung up
|
||||||
close(watched_fds[this_fd].fd);
|
// don't close the file descriptor yet, there might still be data to read
|
||||||
break_out = true;
|
// instead, remove the POLLIN event to avoid getting a POLLHUP event in the next poll() call
|
||||||
break;
|
watched_fds[this_fd].events &= ~POLLIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// wait for child to exit, capture status
|
// wait for child to exit, capture status
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
|
|
||||||
|
while ((byte_count = read(fd_child_stderr_pipe[READ_END], buf, BUFFER_SIZE)) > 0) {
|
||||||
|
write_all(stderr_log_fh->_fileno, buf, byte_count);
|
||||||
|
write_all(STDERR_FILENO, buf, byte_count);
|
||||||
|
}
|
||||||
|
|
||||||
ttyResetExit( &ttyOrig);
|
ttyResetExit( &ttyOrig);
|
||||||
if WIFEXITED(status) {
|
if WIFEXITED(status) {
|
||||||
return WEXITSTATUS(status);
|
return WEXITSTATUS(status);
|
||||||
|
|
Loading…
Reference in New Issue