Attempt to solve race condition with lock files.
If lock_file returns status < 0, do several iterations of sleeping for a short duration and checking again whether the lockfile can be created.
This seems to fix the problem I have been having with knitr and tikz.
Clean up the loop to sleep and check again.
Merge remote-tracking branch 'jonathan-g/master' into next

* jonathan-g/master:
  Clean up the loop to sleep and check again.
  Attempt to solve race condition with lock files. If lock_file returns status < 0, do several iterations of sleeping for a short duration and checking again whether the lockfile can be created. This seems to fix the problem I have been having with knitr and tikz.
Only loop the lockfile creation on Windows platform