Next: , Previous: , Up: Other I/O   [Contents][Index]

5.19.9 Pipes

In addition to using Gforth in pipes created by other processes (see Gforth in pipes), you can create your own pipe with open-pipe, and read from or write to it.

open-pipe ( c-addr u wfam – wfileid wior ) gforth-0.4 “open-pipe”
close-pipe ( wfileid – wretval wior ) gforth-0.4 “close-pipe”

If you write to a pipe, Gforth can throw a broken-pipe-error; if you don’t catch this exception, Gforth will catch it and exit, usually silently (see Gforth in pipes). Since you probably do not want this, you should wrap a catch or try block around the code from open-pipe to close-pipe, so you can deal with the problem yourself, and then return to regular processing.

broken-pipe-error ( – n  ) gforth-0.6 “broken-pipe-error”

the error number for a broken pipe