Manage a process lock using flock(2).
Manage a process lock using flock(2).

The old lock implementation was broken as its 'acquire()` operation
is not atomic. Replace the manual locking mechanism with flock.

fujimotos/Eubin