Weird things in csh (and kernel?)

Kenneth Almquist ka at june.cs.washington.edu
Mon Feb 29 06:40:03 AEST 1988


> % 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 at june.cs.washington.edu



More information about the Comp.unix.wizards mailing list