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

No "waiting for data" message when using F command on a pipe #555

Closed
gwsw opened this issue Aug 5, 2024 · 2 comments
Closed

No "waiting for data" message when using F command on a pipe #555

gwsw opened this issue Aug 5, 2024 · 2 comments

Comments

@gwsw
Copy link
Owner

gwsw commented Aug 5, 2024

Steps to reproduce:

  1. Run i=0; while :; do echo $i; let i=$i+1; sleep .2; done > file &.
  2. Run less file.
  3. Type F.
  4. Note that a "Waiting for data" message appears while content is scrolling.
  5. Exit less.
  6. Run i=0; while :; do echo $i; let i=$i+1; sleep .2; done | less.
  7. Type F.

Expected behavior:
A "Waiting for data" message should appears as in the case of viewing a regular file.

Actual behavior:
No "Waiting for data" message is visible.

@gwsw
Copy link
Owner Author

gwsw commented Aug 7, 2024

Actually the lack of the "waiting for data" message in this case is by design. See #337. The message can be made to appear by setting LESS_DATA_DELAY to a small number (less than 200 in this case). The inconsistency is arguably a problem in the case of viewing a file, in which it's reasonable to argue that the message should NOT appear, similar to the behavior for a pipe. The fact that the message does appear is due to the behavior of poll() which always returns POLLIN for a regular file, even if you are at EOF and no data is actually readable.

gwsw added a commit that referenced this issue Jan 19, 2025
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.
@gwsw
Copy link
Owner Author

gwsw commented Jan 19, 2025

Resolved in 31cd391.
Now in all cases (regular file or fifo), the "waiting for data" message is displayed immediately if the user enters the F command. It is displayed after the LESS_DATA_DELAY timeout if we need to wait for file data on any other command. I think this is the appropriate behavior.

@gwsw gwsw closed this as completed Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant