run-command.c: fix broken list iteration in clear_child_for_cleanup