Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!husc6!think!ames!hc!beta!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.unix.wizards Subject: Re: /dev/stdin for 4.3? Message-ID: <5856@brl-smoke.ARPA> Date: Wed, 13-May-87 13:21:35 EDT Article-I.D.: brl-smok.5856 Posted: Wed May 13 13:21:35 1987 Date-Received: Sat, 16-May-87 05:57:50 EDT References: <7359@brl-adm.ARPA> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 In article <7359@brl-adm.ARPA> prog@braggvax.arpa writes: >This has probably already been asked (and answered) several times, but does >anyone have the code to put the /dev/stdin device in 4.3? This is almost trivial: 1) Implement /dev/fd instead (general file descriptor device), using minor device to select the fd #. Make /dev/stdin a link to /dev/fd/0, similarly for /dev/stdout etc. 2) All you need is the open() entry, which should simply snarf up the process's corresponding file table index, just like a dup() except you don't allocate anything. 3) read(), write(), select(), close(), etc. don't even have to know how you got the fd open. (You'll be using the entries associated with the original non-/dev/fd open, so there need be no entries for these in the /dev/fd driver.) I've seen several implementations but none this simple.