Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!eagle!harpo!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.unix-wizards Subject: Re: unremovable files? Message-ID: <1856@rlgvax.UUCP> Date: Mon, 9-Apr-84 18:19:41 EST Article-I.D.: rlgvax.1856 Posted: Mon Apr 9 18:19:41 1984 Date-Received: Wed, 11-Apr-84 00:25:05 EST References: <373@rdin.UUCP> <142@drutx.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 31 > The file is probably in use by you or someone else. If the > file is listed as being open, unix won't > allow it to be removed until the file is released. It is the same > problem you run into when you try to remove or remake /bin/sh, /etc/getty, > etc. Actually, this isn't the case for open files - UNIX will happily let you unlink open files; the directory entry referencing the file will go away, but the file will remain until the last process using the file closes it. If the file is a shared-text executable image, however, UNIX will not let you remove the last link to it until the last process using that shared text goes away. The reason the latter step was taken, I am told, is that if the system crashed after the directory entry was removed but before the last process finished with it, it would leave an "orphaned" file which "fsck" would complain about. This problem also occurs, however, in the first case (an open file), so it's not clear that the restriction on unlinking active shared-text executables (which arrived in V7, and continued in USG UNIX) is really useful. Berkeley decided it wasn't useful, so 4.xBSD permits you to remove the last link to the file, which makes it easier to remake programs like "/bin/sh". It does mean, however, that you have to remember that any process currently using that executable image will continue to use the old image - only processes invoking the new executable image will get it (which may have been another reason for not permitting the last link to be removed - but, then again, you could rename "/bin/sh" to "/bin/OLDsh" and drop in a new "/bin/sh" anyway). I also removed it recently from our own UNIX port. Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy