mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-10-18 03:33:51 +03:00
command: introduce virPidWait, virPidAbort
When using virCommandRunAsync and saving the pid for later, it is useful to be able to reap that pid in the same way that it would have been auto-reaped by virCommand if we had passed NULL for the pid argument in the first place. * src/util/command.c (virPidWait, virPidAbort): New functions, created from... (virCommandWait, virCommandAbort): ...bodies of these. (includes): Drop duplicate <stdlib.h>. Ensure that our pid_t assumptions hold. (virCommandRunAsync): Improve documentation. * src/util/command.h (virPidWait, virPidAbort): New prototypes. * src/libvirt_private.syms: Export them. * docs/internals/command.html.in: Document them.
This commit is contained in:
@@ -497,6 +497,23 @@
|
||||
error if not.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There are two approaches to child process cleanup, determined by
|
||||
how long you want to keep the virCommand object in scope.
|
||||
</p>
|
||||
|
||||
<p>1. If the virCommand object will outlast the child process,
|
||||
then pass NULL for the pid argument, and the child process will
|
||||
automatically be reaped at virCommandFree, unless you reap it
|
||||
sooner via virCommandWait or virCommandAbort.
|
||||
</p>
|
||||
|
||||
<p>2. If the child process must exist on at least one code path
|
||||
after virCommandFree, then pass a pointer for the pid argument.
|
||||
Later, to clean up the child, call virPidWait or virPidAbort.
|
||||
Before virCommandFree, you can still use virCommandWait or
|
||||
virCommandAbort to reap the process.
|
||||
</p>
|
||||
|
||||
<h3><a name="release">Releasing resources</a></h3>
|
||||
|
||||
|
Reference in New Issue
Block a user