Fix pidfile waiting