run-command: handle dup2 and close errors in child