Compare commits

...

2 Commits

Author SHA1 Message Date
phanes d13793954d possible fix for buffering issue 2024-02-08 15:12:59 -05:00
phanes e9fd8c80bc possible fix for buffering issue 2024-02-08 15:04:52 -05:00
2 changed files with 11 additions and 8 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/bash #!/usr/bin/bash
# #
echo test from script echo test from script
#/usr/bin/dialog --title "This should be one argument" --inputbox "Enter your name:" 0 0 /usr/bin/dialog --title "This should be one argument" --inputbox "Enter your name:" 0 0

View File

@ -235,13 +235,11 @@ int exec_pty(
byte_count = read(watched_fds[this_fd].fd, buf, BUFFER_SIZE); byte_count = read(watched_fds[this_fd].fd, buf, BUFFER_SIZE);
if (byte_count == -1) { if (byte_count == -1) {
if (errno == EAGAIN) { if (errno == EAGAIN) { continue; } else {
// no data to read // error reading from pipe
continue; safe_perror("read", &ttyOrig );
exit(EXIT_FAILURE);
} }
// error reading from pipe
safe_perror("read", &ttyOrig );
exit(EXIT_FAILURE);
} else if (byte_count == 0) { } else if (byte_count == 0) {
// reached EOF on one of the streams but not a HUP // reached EOF on one of the streams but not a HUP
// we've read all we can this cycle, so go to the next fd in the for loop // we've read all we can this cycle, so go to the next fd in the for loop
@ -268,7 +266,7 @@ int exec_pty(
} }
} }
if (watched_fds[this_fd].revents & POLLERR) { if (watched_fds[this_fd].revents & POLLERR) {
close(watched_fds[this_fd].fd); //close(watched_fds[this_fd].fd);
break_out = true; break_out = true;
//continue; //continue;
} }
@ -289,6 +287,11 @@ int exec_pty(
// 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(watched_fds[1].fd, buf, BUFFER_SIZE)) > 0) {
write_all(stdout_log_fh->_fileno, buf, byte_count);
write_all(STDOUT_FILENO, buf, byte_count);
}
while ((byte_count = read(fd_child_stderr_pipe[READ_END], buf, BUFFER_SIZE)) > 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_log_fh->_fileno, buf, byte_count);
write_all(STDERR_FILENO, buf, byte_count); write_all(STDERR_FILENO, buf, byte_count);