* ltmain.in: create on-demand executable as $progdir/$$-$program,

and rename it to $progdir/$program only when it's finished, to
avoid race conditions.  We can still get the program linked
multiple times, if multiple instances are started simultaneously
and the program does not exist, but they are very unlikely to
interfere with each other.  There's still a possibility that one
process removes the $program another has just created, and doesn't
replace it before the other tries to run it, in a system whose
`mv' is not atomic, so it will $rm then $mv, but so what? :-)
Locking files have been avoided to prevent dead-locks in case they
are left over after a reboot or crash.
This commit is contained in:
Alexandre Oliva 1999-02-22 20:47:30 +00:00 committed by Alexandre Oliva
parent 40e8332d43
commit 231f7fd15f
2 changed files with 31 additions and 9 deletions

View File

@ -1,5 +1,17 @@
1999-02-22 Alexandre Oliva <oliva@dcc.unicamp.br>
* ltmain.in: create on-demand executable as $progdir/$$-$program,
and rename it to $progdir/$program only when it's finished, to
avoid race conditions. We can still get the program linked
multiple times, if multiple instances are started simultaneously
and the program does not exist, but they are very unlikely to
interfere with each other. There's still a possibility that one
process removes the $program another has just created, and doesn't
replace it before the other tries to run it, in a system whose
`mv' is not atomic, so it will $rm then $mv, but so what? :-)
Locking files have been avoided to prevent dead-locks in case they
are left over after a reboot or crash.
* TODO: removed ILD, soon to be merged, and added convenience
libraries docs

View File

@ -2544,7 +2544,7 @@ static const void *lt_preloaded_setup() {
fi
if test "$shlibpath_overrides_runpath" != yes; then
compile_for_build_command=`echo "X$compile_command" | $Xsed -e "s%@BUILD_LIBDIRS_FLAGS@%$build_libdirs_flags%" -e "s%@BUILD_RPATH@%$build_rpath%" -e "s%@HARDCODE_BUILD_LIBDIRS@%$build_libdirs%" -e 's%@THISDIR@%\$thisdir%g' -e 's%@OUTPUT@%\$progdir/\$program%g'`
compile_for_build_command=`echo "X$compile_command" | $Xsed -e "s%@BUILD_LIBDIRS_FLAGS@%$build_libdirs_flags%" -e "s%@BUILD_RPATH@%$build_rpath%" -e "s%@HARDCODE_BUILD_LIBDIRS@%$build_libdirs%" -e 's%@THISDIR@%\$thisdir%g' -e 's%@OUTPUT@%\$progdir/\$file%g'`
fi
# Replace the output file specification.
@ -2661,16 +2661,26 @@ else
progdir=\"\$thisdir/$objdir/$objdir\"
if test ! -f \"\$progdir/\$program\" || \\
{ newestfile=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
test \"X\$newestfile\" != \"X\$progdir/\$program\"; }; then
if test ! -d \"\$progdir\"; then
$mkdir \"\$progdir\"
else
$rm \"\$progdir/\$program\"
fi
{ file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
test \"X\$file\" != \"X\$progdir/\$program\"; }; then
file=\"\$\$-\$program\"
$rm \"\$progdir/\$file\""
echo >> $output "\
# link executable that uses uninstalled libraries
(cd \$thisdir && $compile_for_build_command) || exit 1
if (cd \"\$thisdir\" && $compile_for_build_command); then :
else
$rm \"\$progdir/\$file\"
exit 1
fi
$mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
{ $rm \"\$progdir/\$program\";
$mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
$rm \"\$progdir/\$file\"
fi"
fi