Page 1 of 1

peek for WINDOWS

Posted: Mon Sep 07, 2020 5:05 pm
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?