
A better approach would be for the process to open the targetFile with O_EXCL (and create it with O_CREAT if it doesn't exist), and hold it open while doing the atomic rename on top of the target. That way the targetFile is used a lock to synchronise updates between concurrent
#8591: Concurrent executions of ghc-pkg can cause inconstant package.cache files -------------------------------------+------------------------------------- Reporter: janm | Owner: pgj Type: bug | Status: new Priority: normal | Milestone: Component: Package | Version: 7.6.3 system | Keywords: ghc-pkg race Resolution: | Architecture: Unknown/Multiple Operating System: FreeBSD | Difficulty: Unknown Type of failure: Other | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by pgj): Replying to [comment:2 janm]: processes. Does the same problem persist with GHC 7.8.x? Unfortunately, I do not own such a beefy hardware, although I may be able to get some help in that respect from the FreeBSD Project. What is the version of the operating system (that is, ideally {{{OSVERSION}}})? I guess the architecture is {{{amd64}}}. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8591#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler