Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: process the final pipe input event before closing #8

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions t3.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ int main(int argc, char *argv[]) {
pfds[0].revents & POLLIN, pfds[0].revents & POLLPRI,
pfds[0].revents & POLLOUT, pfds[0].revents & POLLERR,
pfds[0].revents & POLLHUP, pfds[0].revents & POLLNVAL);
if ((pfds[0].revents & POLLIN) && !(pfds[0].revents & POLLHUP)) {
if (pfds[0].revents & POLLIN) {
_debug(2, "detected input on stdout_msg_pipe[0]");
struct payload *msg_payload = malloc(sizeof(struct payload));
if (read(stdout_msg_pipe[0], msg_payload, sizeof(struct payload)) >
Expand All @@ -659,7 +659,7 @@ int main(int argc, char *argv[]) {
num_open_fds--;
waitpid(stdout_worker, NULL, WNOHANG);
}
if ((pfds[1].revents & POLLIN) && !(pfds[1].revents & POLLHUP)) {
if (pfds[1].revents & POLLIN) {
_debug(2, "detected input on stderr_msg_pipe[0]");
struct payload *msg_payload = malloc(sizeof(struct payload));
if (read(stderr_msg_pipe[0], msg_payload, sizeof(struct payload)) >
Expand Down
2 changes: 1 addition & 1 deletion tests/midline-flush.args
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-- tests/midline-flush
-- sh -c 'for i in `seq 1 10`; do tests/midline-flush; done'
9 changes: 9 additions & 0 deletions tests/midline-flush.err
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
Hello, stderr! Goodbye, stderr!
Hello, stderr! Goodbye, stderr!
Hello, stderr! Goodbye, stderr!
Hello, stderr! Goodbye, stderr!
Hello, stderr! Goodbye, stderr!
Hello, stderr! Goodbye, stderr!
Hello, stderr! Goodbye, stderr!
Hello, stderr! Goodbye, stderr!
Hello, stderr! Goodbye, stderr!
Hello, stderr! Goodbye, stderr!
18 changes: 18 additions & 0 deletions tests/midline-flush.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
Hello, stderr! Goodbye, stderr!
Hello, stdout! Goodbye, stdout!
Hello, stderr! Goodbye, stderr!
Hello, stdout! Goodbye, stdout!
Hello, stderr! Goodbye, stderr!
Hello, stdout! Goodbye, stdout!
Hello, stderr! Goodbye, stderr!
Hello, stdout! Goodbye, stdout!
Hello, stderr! Goodbye, stderr!
Hello, stdout! Goodbye, stdout!
Hello, stderr! Goodbye, stderr!
Hello, stdout! Goodbye, stdout!
Hello, stderr! Goodbye, stderr!
Hello, stdout! Goodbye, stdout!
Hello, stderr! Goodbye, stderr!
Hello, stdout! Goodbye, stdout!
Hello, stderr! Goodbye, stderr!
Hello, stdout! Goodbye, stdout!
Hello, stderr! Goodbye, stderr!
Hello, stdout! Goodbye, stdout!
9 changes: 9 additions & 0 deletions tests/midline-flush.out
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
Hello, stdout! Goodbye, stdout!
Hello, stdout! Goodbye, stdout!
Hello, stdout! Goodbye, stdout!
Hello, stdout! Goodbye, stdout!
Hello, stdout! Goodbye, stdout!
Hello, stdout! Goodbye, stdout!
Hello, stdout! Goodbye, stdout!
Hello, stdout! Goodbye, stdout!
Hello, stdout! Goodbye, stdout!
Hello, stdout! Goodbye, stdout!
Loading