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

Request procedure: fd-peek #23

Open
jetjinser opened this issue Aug 27, 2024 · 3 comments
Open

Request procedure: fd-peek #23

jetjinser opened this issue Aug 27, 2024 · 3 comments

Comments

@jetjinser
Copy link
Contributor

(fd-peek handle amount) → (or/c string? eof)
  handle : handle?
  amount : (or/c integer? eof 'avail)

I hope that the handle can also be peeked. Unlike fd-read, which consumes data, it retains the data and can be read/peek next time.

I don't know if this makes sense, if I got anything wrong, please correct me.
Thank you for your consideration!

@mflatt
Copy link
Member

mflatt commented Aug 27, 2024

Unfortunately, this would be difficult to add, because file descriptors at the OS level generally do not support peeking. Peeking requires a layer that buffers input from a file descriptor, and adding that to Zuo would be a big change and have all sorts of complicated interactions with processes and pipes.

@jetjinser
Copy link
Contributor Author

jetjinser commented Aug 28, 2024 via email

@lassik
Copy link

lassik commented Aug 30, 2024

The closest Unix system call is probably poll(). It does not tell how many bytes are available to read.

If amount is characters, it cannot be done with variable-length character encodings (e.g. UTF-8) without reading into a buffer.

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

3 participants