From mboxrd@z Thu Jan 1 00:00:00 1970 From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers) Date: Mon, 4 Jun 2012 18:32:36 -0400 Subject: [lttng-dev] [lttng-tools stable-2.0 merge req] Fix: close all file descriptors when executed as daemon Message-ID: <20120604223236.GA30869@Krystal> This commit from lttng-tools master should be merged into stable-2.0: commit ceed52b545103258e84f1c7040700be9dbbbaec6 Author: Mathieu Desnoyers Date: Mon Jun 4 18:08:24 2012 -0400 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 Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com