Skip to content

Commit

Permalink
"waiting for data" msg should appear immediately on F command on a fifo.
Browse files Browse the repository at this point in the history
On a file, poll() returns POLLIN (readable data) even if we are at
end of file. This allows the code in ch_get to see that there is no
data available and display the "waiting for data" message. But on a
fifo, if there is no data available, poll() will block until the
timeout, so at eof on a pipe we will be stuck in the poll and never
display the waiting message. This commit changes the timeout so that
on the first read on a fifo (when there is no waiting message displayed)
we will use timeout=0 and return immediately. This allows ch_get to
display the waiting message. After the message is displayed,
subsequent reads will use an infinite timeout.

Related to #555.
  • Loading branch information
gwsw committed Jan 19, 2025
1 parent 2de3c52 commit 31cd391
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion os.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void init_poll(void)
static int check_poll(int fd, int tty)
{
struct pollfd poller[2] = { { fd, POLLIN, 0 }, { tty, POLLIN, 0 } };
int timeout = (waiting_for_data && !(scanning_eof && follow_mode == FOLLOW_NAME)) ? -1 : waiting_for_data_delay;
int timeout = (waiting_for_data && !(scanning_eof && follow_mode == FOLLOW_NAME)) ? -1 : (ignore_eoi && !waiting_for_data) ? 0 : waiting_for_data_delay;
if (!any_data)
{
/*
Expand Down

0 comments on commit 31cd391

Please sign in to comment.