Next: , Previous: , Up: posix fd   [Index]


4.13.10 File descriptor pipes

Function: pipe

Interface to the C function pipe(), (libc)pipe. Create a pair of file descriptors connected through a pipe. If successful return two values being fixnums representing the file descriptors, else raise an exception.

The following is a simple example of process writing to itself through a pipe:

#!r6rs
(import (vicare)
  (prefix (vicare posix) px.))

(receive (in ou)
    (px.pipe)
  (px.write ou '#vu8(1 2 3 4) 4)
  (receive-and-return (bv)
      (make-bytevector 4)
    (px.read in bv 4)))
⇒ #vu8(1 2 3 4)