![](https://secure.gravatar.com/avatar/7d19e6b2520f265ddf2121b2c29cc0d9.jpg?s=120&d=mm&r=g)
Bugs item #1242, was opened at 2008-06-06 14:53
Status: Open Priority: 3 Submitted By: William Blum (wblum) Assigned to: Nobody (None) Summary: pdftex opens the .pdf output file with write sharing access Resolution: Invalid Group: None Category: None
Initial Comment: pdftex v1.40.7 opens the output .pdf file with write sharing access (at least on the Miktex distribution). This is bad for many reasons (and can actually be an indirect cause of file locking problems in some situations). This means that you can start two instances of pdftex on the same .tex file without getting any error, the writing operations gets interleaved and you end up with a corrupt .pdf. pdftex should open the file with read sharing access only. If the file is opened using the C++ fstream::open function then this means setting the protection mode to 'filebuf::sh_read' but not to 'filebuf::sh_write'. That way if another instance is running, it will prevent the new instance from writing into the file. ----------------------------------------------------------------------
Comment By: Taco Hoekwater (taco) Date: 2008-06-07 09:39
Message: I can see this is can easily be a problem everywhere, especially in networked environments, so will reopen the report, but file locking is probably not the best way to fix the symptoms. Locking files (and detecting locks) on a local harddisk is already quite hard to implement in a portable manner, never mind attempting todo the same over a network share. So if you really want file locking, you probably should talk to the miktex maintainer, as that is not likely to make it into pdftex (or luatex)'s core distribution. However, it would be pretty easy to make pdftex create a PDF file with a temporary name and rename it only at the end of a succesful run. As a side bonus, that would also prevent the existance of partial == broken pdfs. I believe that is something to consider for 1.50 or luatex. ---------------------------------------------------------------------- Comment By: William Blum (wblum) Date: 2008-06-06 23:20 Message:
We don't support MikTeX-pdfTeX; please discuss this with the MikTeX maintainer.
This bug does not affect only MikTex! I have just tried with teTeX on cygwin and the same problem occurs. I suspect that all TeX distributions suffer from the same bug since there is no reason for them to change the way the files are opened by pdftex. Since all distributions derive from the pdftex code maintained here, I though it would make more sense to patch the bug at the source... ---------------------------------------------------------------------- Comment By: Martin Schröder (oneiros) Date: 2008-06-06 15:45 Message: We don't support MikTeX-pdfTeX; please discuss this with the MikTeX maintainer. ---------------------------------------------------------------------- You can respond by visiting: http://sarovar.org/tracker/?func=detail&atid=493&aid=1242&group_id=106