Make singleinstance() more robust on OS X

It now handles EINTR and also does not hide all errors in opening the
file or calling lockf()

An error is now reported to the user in a nice error dialog before
aborting startup.
Small perf improvement
More work on the completion worker