Merge pull request #5 from mk01/master-mk01

rewrite of locking of pid and client/server detection
put one more barrier to locking of first pid file.
for systems which lack support of "x" in fopen mode