next up previous
Next: 2.12 Passing File Descriptors Up: 2. Environmentally Friendly I/O Previous: 2.10 Automatically Opened Files

  
2.11 Opening Streams Over File Descriptors

In all the definitions in this chapter so far, the first argument to open has been a string giving a filename, command, signal type name, or number of milliseconds, but it can actually be an integer file descriptor, which may for example have been inherited, or produced by one of the low-level routines listed in Section 2.17.1 [I/O and File Descriptors]. A major use of the `rw' I/O mode (Section 2.3 [Sequential and Direct-Access I/O]) is in fact to obtain a SETL stream over an inherited file descriptor about which the inheritor knows and cares nothing except that the stream is bidirectional. There is an example of this in the program lengths.setl in Section 3.2.2 [Shell-Aided Server].

A pseudo-fd returned by open for a signal or timer stream cannot be used as a first argument to open. It would not be a very useful feature, since signal handlers do not survive the exec calls implicit in exec (Section 2.17.2 [Processes]), system, filter, and pipe or pump stream open (Section 2.2 [Filters, Pipes, and Pumps]) calls.


next up previous
Next: 2.12 Passing File Descriptors Up: 2. Environmentally Friendly I/O Previous: 2.10 Automatically Opened Files
David Bacon
1999-12-10