
pipe(?StreamIn, ?StreamOut)

   Creates a pipe and two streams StreamIn and StreamOut to its read and write ends

Arguments
   StreamIn            Atom or variable.
   StreamOut           Atom or variable.

Type
   Stream I/O

Description
   Opens a pipe, i.e.  two streams, StreamIn for for reading and StreamOut
   for writing, which are connected together.  This can be used, for
   example, to temporarily store data instead of writing it to a file.


   Prolog data Data may be written using write( StreamOut,Data).  Note that
   in order to read data using read/1,2, it must have been written in
   Prolog term format (i.e.  ended with a period and a blank space
   character).  Before reading is possible the output must be flushed with
   the call flush(StreamOut).


   When instantiated, StreamIn and StreamOut can be symbolic stream names
   (atom) or physical stream numbers (integer).


   Each stream can also be specified as sigio(Stream) (BSD systems only).
   In this case a pipe is set up and in addition it is instructed to send
   the signal io each time new data appears in it.  In this way it is
   possible to set up an interrupt handler that reads the data from the
   pipe and behaves as a lightweight consumer process.


   Note that when StreamIn is closed, writing to StreamOut will cause
   signal 13.




Modes and Determinism
   pipe(-, -) is det
   pipe(+, +) is det

Exceptions
     5 --- Either StreamIn or StreamOut is instantiated, but not to an    atom or a sigio structure.
   193 --- StreamIn or StreamOut have wrong mode or are equal.

Examples
   
Success:
      pipe(a,b).

      [eclipse]: pipe(in, out), printf(out, "a. %b", []), read(in, A).

      A = a
      yes.
Error:
      pipe(0,1).           (Error 5).
      pipe(26.9,M).        (Error 5).
      pipe(output, X).     (Error 193).
      pipe(a, a).          (Error 193).





See Also
   open / 3, open / 4, close / 1, get_stream_info / 3, select / 3
