Fixed the handling of IPv6, and added a permission check for the pid file