Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!oliveb!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: File descriptors Message-ID: <19531@sun.uucp> Date: Fri, 22-May-87 02:42:21 EDT Article-I.D.: sun.19531 Posted: Fri May 22 02:42:21 1987 Date-Received: Sat, 23-May-87 14:47:02 EDT References: <2532@ncoast.UUCP> <5875@brl-smoke.ARPA> <1673@tekcrl.TEK.COM> Sender: news@sun.uucp Lines: 38 > All of this is true for Berkeley 4.2/4.3 (I just looked at the code just > to make sure 4.3 didn't change what file descriptors mean). I have absolutely > no idea if this is the way System V does things. Well, this happens to be one of the things that has remained pretty much constant in UNIX implementations since at least V6 (and probably back further than that). 4.3 didn't change anything of consequence (which isn't really surprising - there's really little that needs changing), and neither 4.2BSD, nor System III, nor System V, introduced any major changes. (The only change 4.2BSD made was to have objects other than inodes attached to a file table entry; Bill Shannon noted that, given a system with multiple "file system types", it might have been possible to use that mechanism instead.) The distinction between a file descriptor (i.e., either the small number you get back from "open", "dup", etc.) and a file table entry (the entry in the system-wide table that indicates things like the current seek pointer) is not significant in most cases, so Doug's description is, at worst, a slight over-simplification. The only per-file-descriptor state in the system is the "close on 'exec'" flag. Most operations treat all file descriptors that refer to the same file table entry as equivalent. To quote from the S5R3 manual page DUP(2): "dup" returns a new file descriptor having the following in common with the original: Same open file (or pipe). Same file pointer (i.e., both file descriptors share one file pointer). Same access mode (read, write or read/write). which describes most of the state stored with a file descriptor. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com