Handle locking via pid files