aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-07-12 10:42:41 -0600
committerEric Blake <eblake@redhat.com>2011-07-14 11:56:30 -0600
commite208c38b4908692bc83c81af85bcffbb1c7a5db3 (patch)
treebc10a04b74c7d71ee8f2dae7120aab37c6ac8eba /docs/internals
parentupdate apparmor security driver for new udev paths (diff)
downloadlibvirt-e208c38b4908692bc83c81af85bcffbb1c7a5db3.tar.gz
libvirt-e208c38b4908692bc83c81af85bcffbb1c7a5db3.tar.bz2
libvirt-e208c38b4908692bc83c81af85bcffbb1c7a5db3.zip
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.
Diffstat (limited to 'docs/internals')
-rw-r--r--docs/internals/command.html.in17
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/internals/command.html.in b/docs/internals/command.html.in
index 27dcf9c4d..8a194ec95 100644
--- a/docs/internals/command.html.in
+++ b/docs/internals/command.html.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>