1 Sometimes a shell script needs to prevent itself from being called multiple
 
   4 This is a locking problem:
 
   5 http://wiki.bash-hackers.org/howto/mutex
 
   6 https://gist.github.com/przemoc/571091
 
   8 However, in case where the script in question prepares the work for some other
 
   9 operation (e.g. the script is a "pre hook") it is typically called from
 
  10 another program, interleaved with other processes, and so locking and
 
  11 unlocking cannot be in the same script.
 
  13 By using a symmetrical "post hook", assuming that it is called by the same
 
  14 process which called the "pre hook", the parent PID can be used as a condition
 
  15 value, thus locking and unlocking can be performed in two distinct scripts.