libvirt/daemon
Eric Blake e957b67061 daemon: clean up daemonization
Valgrind detected a pipe fd leak before the parent exits on success,
introduced in commit 4296cea; by itself, the leak is not bad, since
we immediately called _exit(), but we might as well be clean to make
valgrind analysis easier.  Meanwhile, if the daemon grandchild detects
an error, the parent failed to flush the error message before exiting.
Also, we had the possibility of both parent and child returning to the
caller, such that the user could see duplicated reports of failure
from the two return paths.  And we might as well be robust to the
(unlikely) situation of being started with stdin closed.

* daemon/libvirtd.c (daemonForkIntoBackground): Use exit if an
error message was generated, avoid fd leaks for valgrind's sake,
avoid returning to caller in both parent and child, and don't
close a just-dup'd stdin.
Based on a report by Alex Jia.

* How to reproduce?
  % service libvirtd stop
  % valgrind -v --track-fds=yes /usr/sbin/libvirtd --daemon

* Actual valgrind result:

==16804== FILE DESCRIPTORS: 7 open at exit.
==16804== Open file descriptor 7:
==16804==    at 0x321FAD8B87: pipe (in /lib64/libc-2.12.so)
==16804==    by 0x41F34D: daemonForkIntoBackground (libvirtd.c:186)
==16804==    by 0x4207A0: main (libvirtd.c:1420)

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2011-12-28 05:14:38 -07:00
..
.gitignore Add support for systemd init service 2011-11-18 16:16:02 +00:00
libvirtd.aug Implement keepalive protocol in libvirt daemon 2011-11-24 11:44:08 +01:00
libvirtd.c daemon: clean up daemonization 2011-12-28 05:14:38 -07:00
libvirtd.conf maint: typo fixes 2011-12-01 16:08:34 -07:00
libvirtd.h Implement keepalive protocol in libvirt daemon 2011-11-24 11:44:08 +01:00
libvirtd.init.in daemon: Don't remove pidfiles in init scripts 2011-09-27 10:53:46 +02:00
libvirtd.logrotate.in Add logrotate support for libvirtd.log 2011-03-04 22:43:55 +08:00
libvirtd.lxc.logrotate.in Change logrotate to be per-hypervisor logs 2010-03-10 11:27:02 +01:00
libvirtd.pod.in docs: removed outdated reference to virt-mem 2010-11-23 01:11:10 +11:00
libvirtd.policy-0 Rename qemud/ directory to daemon/ 2009-09-21 14:41:42 +01:00
libvirtd.policy-1 Rename qemud/ directory to daemon/ 2009-09-21 14:41:42 +01:00
libvirtd.qemu.logrotate.in Change logrotate to be per-hypervisor logs 2010-03-10 11:27:02 +01:00
libvirtd.sasl Rename qemud/ directory to daemon/ 2009-09-21 14:41:42 +01:00
libvirtd.service.in Add support for systemd init service 2011-11-18 16:16:02 +00:00
libvirtd.sysconf Add support for systemd init service 2011-11-18 16:16:02 +00:00
libvirtd.sysctl init: raise default system aio limits 2011-10-05 14:49:35 -06:00
libvirtd.uml.logrotate.in Change logrotate to be per-hypervisor logs 2010-03-10 11:27:02 +01:00
libvirtd.upstart daemon: Don't remove pidfiles in init scripts 2011-09-27 10:53:46 +02:00
Makefile.am build: follow directory install conventions 2011-12-12 10:26:57 -07:00
remote.c Add virDomain{G, S}etNumaParameters support to the remote driver 2011-12-20 10:47:17 -07:00
remote.h Remove unused virNetServerProgramErrorHander typedef 2011-07-13 11:47:01 +01:00
stream.c maint: fix improper use of 'an' 2011-12-03 17:11:56 -07:00
stream.h Ensure client streams are closed when marking a client for close 2011-08-16 14:38:11 -07:00
test_libvirtd.aug Allow certificate sanity checking to be disabled 2011-07-22 15:18:32 +01:00
THREADS.txt maint: use consistent file name for threading notes 2011-05-31 13:54:45 -06:00