Xref: utzoo comp.unix.questions:5864 comp.unix.wizards:6748 Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!decvax!mcnc!gatech!bloom-beacon!mit-eddie!uw-beaver!uw-june!ka From: ka@june.cs.washington.edu (Kenneth Almquist) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: Weird things in csh (and kernel?) Message-ID: <4320@june.cs.washington.edu> Date: 28 Feb 88 20:40:03 GMT References: <1193@ark.cs.vu.nl> Organization: U of Washington, Computer Science, Seattle Lines: 34 Summary: Down with ETXTBSY! > % a.out < a.out > a.out: Text file busy. > % The basic problem that the "text file busy" error was designed to solve is this. When several copies of the same program are run concurrently, UNIX will only create a text segment for the first copy. Subsequent invocations of the program will reuse this text segment rather than creating a new one. The problem with this approach is that if a program is modified, the system may continue to reuse the old version of the text segment rather than using the new version. This problem was avoided by making the following actions illegal: 1) Opening a file that is being executed. 2) Executing an open file. 3) Deleting the last link to a file that is being executed. So when you say "a.out < a.out", the shell opens a.out and then tries to execute it. The attempt to execute it fails due to rule 2. You are presumably running some version of 2 BSD; both 4 BSD and System V have relaxed rules 1 and 2 to allow files that are being executed to be opened for reading and vice versa. My view is that these rules should be eliminated all together. They are inconvenient, since they make program installation harder. They are inconsistent with the rest of the design of the UNIX file system calls, which permits any operation to be performed at any time (even operations like deleting other people's current working directories). It is a bit simpler to enforce these rules than to design things so that they are unnecessary, but given the growth of the kernel in recent years it is hard to justify taking some of the complexity of supporting shared text out of the kernel and pushing it onto the users. Kenneth Almquist ka@june.cs.washington.edu