[lttng-dev] [lttng-tools stable-2.0 merge req] Fix: close all file descriptors when executed as daemon

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Mon Jun 4 18:32:36 EDT 2012


This commit from lttng-tools master should be merged into stable-2.0:

commit ceed52b545103258e84f1c7040700be9dbbbaec6
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
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 at efficios.com>

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list