Merge pull request #77 from cespare/bsd-deadlock-fix

Fix deadlock on BSD