[net.bugs.4bsd] 4.[123]bsd sh misnames temporary files

ado@elsie.UUCP (Arthur David Olson) (02/23/86)

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