Next: , Previous: Line input and conversion, Up: Other I/O


5.19.8 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       “open-pipe”

close-pipe       wfileid – wretval wior        gforth       “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       “broken-pipe-error”

the error number for a broken pipe