]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* ltmain.in: create on-demand executable as $progdir/$$-$program,
authorAlexandre Oliva <oliva@dcc.unicamp.br>
Mon, 22 Feb 1999 20:47:30 +0000 (20:47 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Mon, 22 Feb 1999 20:47:30 +0000 (20:47 +0000)
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.

ChangeLog
ltmain.in

index a8cfd687e4ed1fb345dd0f59853d0f89aeb320bd..b130c58c9b6c1e982210b2cd25b7a5f106868b52 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
 
index d934fc521042584409d6e5cf03ac7de130e1924a..fe1dedd82fa64965cd7a9c99f93882c5167f86b7 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -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\"
+     { 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
+    if (cd \"\$thisdir\" && $compile_for_build_command); then :
     else
-      $rm \"\$progdir/\$program\"
+      $rm \"\$progdir/\$file\"
+      exit 1
     fi
 
-    # link executable that uses uninstalled libraries
-    (cd \$thisdir && $compile_for_build_command) || exit 1
+    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $rm \"\$progdir/\$program\";
+      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $rm \"\$progdir/\$file\"
   fi"
        fi