Index: dol.c =================================================================== RCS file: /mnt/ncvs/src/bin/csh/Attic/dol.c,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -u -r1.8.2.1 -r1.8.2.2 --- dol.c 1999/08/29 14:11:42 1.8.2.1 +++ dol.c 2000/11/05 21:34:27 1.8.2.2 @@ -40,6 +40,7 @@ #endif #endif /* not lint */ +#include #include #include #include @@ -850,13 +851,20 @@ Char **vp; bool quoted; char *tmp; + struct timeval tv; - if (creat(tmp = short2str(shtemp), 0600) < 0) - stderror(ERR_SYSTEM, tmp, strerror(errno)); - (void) close(0); - if (open(tmp, O_RDWR) < 0) { +again: + tmp = short2str(shtemp); + if (open(tmp, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600) < 0) { int oerrno = errno; - + if (errno == EEXIST) { + if (unlink(tmp) == -1) { + (void) gettimeofday(&tv, NULL); + shtemp = Strspl(STRtmpsh, putn((((int)tv.tv_sec) ^ + ((int)tv.tv_usec) ^ ((int)getpid())) & 0x00ffffff)); + } + goto again; + } (void) unlink(tmp); errno = oerrno; stderror(ERR_SYSTEM, tmp, strerror(errno));