Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: net.bugs.4bsd Subject: 4.[123]bsd sh misnames temporary files (with fix) Message-ID: <6024@elsie.UUCP> Date: Sun, 23-Feb-86 13:56:12 EST Article-I.D.: elsie.6024 Posted: Sun Feb 23 13:56:12 1986 Date-Received: Wed, 26-Feb-86 04:57:36 EST Organization: NIH-LEC, Bethesda, MD Lines: 35 Keywords: bsd sh Index: bin/sh/main.c Fix Description: Temporary files created by /bin/sh are given names of the form /tmp/sh$$$serial where "$$" above is the process identifier of the shell and "$serial" is a serial number that starts at zero. This means that the first temporary file created by process number 321 is given the same name as the eleventh temporary file created by process 32--with potentially disastrous results. Repeat-By: The light of a blue moon. Fix: Use the form /tmp/sh$$.$serial for temporary file names. Here's one way to do it with the 4.1bsd version of "sh/main.c", an addition conditionally compiled based on "OLDVERSION" (where, as usual, the trade secret status of the code involved precludes a clearer posting): settmp() { itos(getpid()); serial=0; tmpnam=movstr(numbuf,&tmpout[TMPNAM]); #ifndef OLDVERSION tmpnam = movstr(".", tmpnam); #endif } -- Sh is an American Librarians Association trademark. -- UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado@seismo.ARPA DEC, VAX and Elsie are Digital Equipment and Borden trademarks