peek for WINDOWS

Started by IVShilov, September 07, 2020, 10:05:35 AM

Previous topic - Next topic

IVShilov

Hi there.

I found that it works like peek on WINDOWS:
(define (peek-pipe fd)
  (letn (pos (seek fd)
    size (seek fd -1))
    (seek fd pos)
    size
    ))

so now we can safely read a pipe from a subprocess without risk of blocking:
(define (read-pipe fd)
  (letn (buf "")
    (read fd buf (peek-pipe fd))
    buf
    ))


Can it be replacement for peek?

Any other comments?