mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
util: make it easier to grab only regular process exit
Right now, a caller waiting for a child process either requires the child to have status 0, or must use WIFEXITED() and friends itself. But in many cases, we want the middle ground of treating fatal signals as an error, and directly accessing the normal exit value without having to use WEXITSTATUS(), in order to easily detect an expected non-zero exit status. This adds the middle ground to the low-level virProcessWait; the next patch will add it to virCommand. * src/util/virprocess.h (virProcessWait): Alter signature. * src/util/virprocess.c (virProcessWait): Add parameter. (virProcessRunInMountNamespace): Adjust caller. * src/util/vircommand.c (virCommandWait): Likewise. * src/util/virfile.c (virFileAccessibleAs): Likewise. * src/lxc/lxc_container.c (lxcContainerHasReboot) (lxcContainerAvailable): Likewise. * daemon/libvirtd.c (daemonForkIntoBackground): Likewise. * tools/virt-login-shell.c (main): Likewise. * tools/virsh-domain.c (cmdLxcEnterNamespace): Likewise. * tests/testutils.c (virtTestCaptureProgramOutput): Likewise. * tests/commandtest.c (test23): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
1 parent
8b24a803ad
commit
c72e76c3d9
10 files changed
+51
-43
No files matched your search
@@ -8206,7 +8206,7 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *cmd)
|
||||
execv(cmdargv[0], cmdargv);
|
||||
_exit(255);
|
||||
} else {
|
||||
if (virProcessWait(pid, NULL) < 0)
|
||||
if (virProcessWait(pid, NULL, false) < 0)
|
||||
_exit(255);
|
||||
}
|
||||
_exit(0);
|
||||
@@ -8214,7 +8214,7 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *cmd)
|
||||
for (i = 0; i < nfdlist; i++)
|
||||
VIR_FORCE_CLOSE(fdlist[i]);
|
||||
VIR_FREE(fdlist);
|
||||
if (virProcessWait(pid, NULL) < 0)
|
||||
if (virProcessWait(pid, NULL, false) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
@@ -369,9 +369,9 @@ main(int argc, char **argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return virProcessWait(ccpid, &status2);
|
||||
return virProcessWait(ccpid, &status2, true);
|
||||
}
|
||||
ret = virProcessWait(cpid, &status);
|
||||
ret = virProcessWait(cpid, &status, true);
|
||||
|
||||
cleanup:
|
||||
virConfFree(conf);
|
||||
|
||||
Reference in new issue
Block a user