From 31cd391dd47e09b501fe20ad6fe3363c2a5d2225 Mon Sep 17 00:00:00 2001 From: Mark Nudelman Date: Sun, 19 Jan 2025 11:14:07 -0800 Subject: [PATCH] "waiting for data" msg should appear immediately on F command on a fifo. 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. --- os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os.c b/os.c index 7ddbbcb4..8f783f49 100644 --- a/os.c +++ b/os.c @@ -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) { /*