This sometimes (often) results in child process being unable to do any further locking with the error 37 (no locks available).Removing fcntl and doing an explicit close of all open file desciprotrs in the beginning of child leads to the same problem.