From a132f019fb73754e8e15d500321e635b51486ee3 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 2 Nov 2016 21:35:12 +0000 Subject: sync with source (for race condition fix attempt) git-svn-id: svn://tug.org/texlive/trunk@42426 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/web2c/mktexdir | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'Master/texmf-dist/web2c/mktexdir') diff --git a/Master/texmf-dist/web2c/mktexdir b/Master/texmf-dist/web2c/mktexdir index f39408b4c1f..86d34f81df7 100755 --- a/Master/texmf-dist/web2c/mktexdir +++ b/Master/texmf-dist/web2c/mktexdir @@ -1,12 +1,13 @@ #!/bin/sh -# mkinstalldirs (now mktexdir) -- make directory hierarchy. +# mktexdir (was mkinstalldirs) -- make directory hierarchy. # Author: Noah Friedman , created: 1993-05-16. # Public domain. # # Modified for sticky directory creation, --help, --version, more, # by Thomas Esser, Karl Berry, Olaf Weber, et al. +# Maintained as part of TeX Live, http://tug.org/tex-live. -version='$Id: mktexdir 34656 2014-07-18 23:38:50Z karl $' +version='$Id: mktexdir 42425 2016-11-02 21:34:11Z karl $' progname=`echo $0 | sed 's%.*/%%'` # preferentially use subprograms from our own directory. @@ -50,7 +51,18 @@ do pathcomp="$pathcomp$d" if test ! -d "./$pathcomp"; then - mkdir "./$pathcomp" || { errstatus=$?; break; } + # This shell stuff is not atomic, therefore ./$pathcomp + # may have been created in another process and this mkdir will + # fail despite the above test, so do it silently: + mkdir "./$pathcomp" >/dev/null 2>&1 + + # So, if ./$pathcomp is a directory now, call it good. + if test ! -d "./$pathcomp"; then + # Otherwise, presumably it's a real error. Do the mkdir again + # and let the error be seen, and quit the loop. + # (Report at https://bugs.debian.org/794228.) + mkdir "./$pathcomp" || { errstatus=$?; break; } + fi chmod `kpsestat ${MT_APPEND_MASK} "$pathcomp"/..` "./$pathcomp" fi @@ -59,3 +71,6 @@ do done exit $errstatus + +# P.S. We don't want to rely on mkdir -p, because of possible +# portability programs. See current mkinstalldirs source (in Automake). -- cgit v1.2.3