apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 57671] New: apr_proc_detach() should close ALL file descriptors
Date Fri, 06 Mar 2015 10:13:25 GMT

            Bug ID: 57671
           Summary: apr_proc_detach() should close ALL file descriptors
           Product: APR
           Version: 1.4.5
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
          Assignee: bugs@apr.apache.org
          Reporter: hahn@univention.de

apr_proc_detach() (as called by apache-2.2.22) does only close STDIN, STDOUT,
STDERR, but not all other (open) file descriptors.

This is problematic when apache2 is restarted from an unclean environment,
where other file descriptors are opened and are pipes, as this happens for
example with <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=713967>: As the
forked Apache process inherits the pipe, it is considered a potential writer,
so any reading will block indefinitely instead of getting an EOF.

(Daemons not closing all file descriptors is a common problem, for which
DebConf has an extra FQA entry:

As far as I know daemons should close all file descriptors:
- <http://linux.die.net/man/1/daemonize>
- <http://stackoverflow.com/questions/17954432/creating-a-daemon-in-linux>
- <http://en.wikipedia.org/wiki/Daemon_(computing)#Creating>

Closing all open file descriptors is somehow problematic, as there is no
portable function for it. Because of that daemons normally implement a loop to
close all FDs:

    int x;
    for (x = sysconf(_SC_OPEN_MAX); x>0; x--)
        close (x);

For Linux one can optimize that by using apr_dir_open(..., "/proc/self/fd",
...) to only close the open FDs.

IMHO apr_proc_detach() should implement the generic close-all-FDs semantic
instead of only Apache-httpd doing it.

You are receiving this mail because:
You are the assignee for the bug.

To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org

View raw message