peek for WINDOWS

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Post Reply
IVShilov
Posts: 18
Joined: Wed Apr 12, 2017 1:58 am

peek for WINDOWS

Post by IVShilov »

Hi there.
I found that it works like peek on WINDOWS:

Code: Select all

(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:

Code: Select all

(define (read-pipe fd)
  (letn (buf "")
    (read fd buf (peek-pipe fd))
    buf
    ))
Can it be replacement for peek?
Any other comments?

Post Reply