[tex-live] Solution to the file locking problem during update (was: Installation problems on Windows Vista)
T T
t34www at googlemail.com
Tue Dec 23 02:25:46 CET 2008
On Mon Dec 1, Norbert Preining wrote:
> On Mo, 01 Dez 2008, Lars Madsen wrote:
> > Could one wrap tlmgr? such that it is another program that starts tlmgr,
> > and then when tlmgr is finished it looks for an update file, and runs it
> > if it is present.
>
> Programmers wanted ...
Sorry to resurect this discussion but I would like to suggest a
solution to the file locking problem.
A typical approach to update locked files on Windows (including
currently running binary) is to launch a child process that waits for
the parent to terminate and then performs an update. This could work
as follows:
Perl script opens a file 'tlmgr.lock', launches 'selfupdate.bat' and
terminates. System will automatically release any open handles upon
process termination so there is no need to close 'tlmgr.lock'
beforehand.
The 'selfupdate.bat' waits until 'tlmgr.lock' unlocks and performs an
update. This could look something like this:
::BOF selfupdate.bat
@echo off
:wait
rem wait ~1sec
ping -n 1 -w 1000 1.1.1.1
rem check if lock file has been released
type nul>tlmgr.lock
if errorlevel 1 goto wait
del tlmgr.lock
rem here goes the update
call updater.bat
rem optionally restart tlmgr
tlmgr gui
rem kill yourself
del "%~f0"
::EOF
And that's about it.
Lock file could be also used to prevent multiple instances of tlmgr.
Right now this is not the case. I can't imagine any reason for
allowing multiple instances of the package manager.
Cheers,
Tomek
More information about the tex-live
mailing list