[ Obsolete | Reference Manual | Alphabetic Index ]

pipe(?StreamIn, ?StreamOut)

Creates a pipe and two streams StreamIn and StreamOut to its read and write ends
Atom or variable.
Atom or variable.

This built-in predicate is obsolete!


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).

StreamIn and StreamOut can be symbolic stream names (atom) or variable, in which case they will get instantiated to stream handles.

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


(5) type error
Either StreamIn or StreamOut is instantiated, but not to an atom or a sigio structure.
(193) illegal stream specification
StreamIn or StreamOut have wrong mode or are equal.



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

      A = a
      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, stream_select / 3