diff --git a/src/util/command.c b/src/util/command.c index d62d9d1a15cc11af0cbbd25aecdba1dafdb45329..5394a02f73a6a964d2eb4f69d86c91a482a66fb9 100644 --- a/src/util/command.c +++ b/src/util/command.c @@ -394,6 +394,10 @@ virExecWithHook(const char *const*argv, } if (pid) { /* parent */ + if (forkRet < 0) { + goto cleanup; + } + VIR_FORCE_CLOSE(null); if (outfd && *outfd == -1) { VIR_FORCE_CLOSE(pipeout[1]); @@ -404,10 +408,6 @@ virExecWithHook(const char *const*argv, *errfd = pipeerr[0]; } - if (forkRet < 0) { - goto cleanup; - } - *retpid = pid; if (binary != argv[0])