rust-lang/cargo — pull request #368 by alexcrichton (2014-08-13 23:29:23+00:00)
Title: Lock all cargo invocations with an OS semaphore.

Using cargo concurrently on the same system often results in badness such as
corruption of the global git database, corruption of the local target directory,
corruption of output artifacts, etc. This is a pretty rare situation, but is
quite troubling to track down when it occurs.

To prevent this badness, cargo needs some method of synchronizing with other
cargo processes. This is often done with a file lock, but sadly file locks are
difficult to use correctly on linux and other flavors of unix [1].

Instead, another mechanism, an OS semaphore, is used. Semaphores provide the
exact functionality that is required here as there's no real need to lock a file
but rather just synchronize with another process. I wrote external bindings for
these semaphores [2] instead of bundling it directly in cargo itself.

Currently only windows, linux, and OSX are supported in ipc-rs, but adding new
platforms with System V compatibility is just a matter of looking up some
constants (nothing too too hard).

[1]: http://0pointer.de/blog/projects/locking.html
[2]: https://github.com/alexcrichton/ipc-rs