Fix 100% CPU due to waitpid