Checking in pidfile locking code. Buggy, but want to save it even as we go after another approach.