38 lines · 1.5 KB · Text
RawDownload
= pipe: create an interprocess channel     include "sys.m";    sys := load Sys Sys->PATH;     pipe: fn(fds: array of ref FD): int; Pipe creates a buffered channel for interprocess I/O via filedescriptors.  It allocates a pipe from the  pipe  device  andreturns  in  the  array fds file descriptors for the two pipeends. Both returned file  descriptors  are  opened  for  bothreading  and  writing (Sys->ORDWR).  Data written on one filedescriptor can be read from the other.  The details  of  flowcontrol  and  buffering are given in pipe(3).  When no refer‐ences remain to the file descriptor representing one end of apipe,  and all remaining data has been read at the other end,subsequent reads at that end will return 0 bytes.  Writes  toa pipe with no reader produce an exception. The array fds passed to the system call must have a length ofat least 2; only entries 0 and 1 are updated. Limbo applications typically use typed  Limbo  channels,  notpipes,  for efficient communication by cooperating processes.Pipes are still useful, however, to connect applications thatdo  not  (or  cannot)  share  such channels, or when a systeminterface  requires  a  file  descriptor.   For  instance,  aprocess  that  serves  the  9P  protocol  can  pass  the filedescriptor for one end of a  pipe  to  Sys->mount  (see  sys-bind(2)),  and read and write 9P messages on the other end ofthe pipe. == diagnosticsReturns 0 on success; -1 on failure. == see ALSOpipe(3)