Fix: close all file descriptors when executed as daemon
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 4 Jun 2012 22:08:24 +0000 (18:08 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 4 Jun 2012 22:08:24 +0000 (18:08 -0400)
commitceed52b545103258e84f1c7040700be9dbbbaec6
tree45dea7cae1d8327cfff453bf4d906f1e54cb2c91
parentda0bdb87642b93f9cb657d68a566683a18ce15c3
Fix: close all file descriptors when executed as daemon

Both sessiond and consumerd support the option "-d" to run as daemon. In
some specific cases, e.g. when launched from dpkg installation scripts,
file descriptors 3, 4, 5 are left open and don't seem to have O_CLOEXEC
flag set, so the install script hangs because the sessiond still holds a
reference to them. daemon(3) only closes standard FD 0, 1, 2.

Fix this issue by closing all file descriptors after calling daemon(3).
Note: we make sure no file descriptor is opened before calling daemon(3)
by moving the init_thread_quit_pipe() call after the FD close.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/bin/lttng-consumerd/lttng-consumerd.c
src/bin/lttng-sessiond/main.c
This page took 0.036116 seconds and 4 git commands to generate.