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