generator: Acquire lock to prevent two parallel runs of the generator.
This commit acquires a lock on a file to prevent two parallel runs of
the generator from stomping on each other. The second run will wait
for the first to complete before starting.
The lock is acquired on the "HACKING" file because it's convenient --
we are already checking this file exists to make sure that we don't
start off in the wrong directory.
Tested by adding some artificial sleeps in the code to observe
locking behaviour between two parallel runs.