Re: [autofs] automount does not close file descriptors at start

Valdis.Kletnieks_at_vt.edu
Date: 02/21/05

  • Next message: Miles Bader: "Re: [darcs-users] Re: [BK] upgrade will be needed"
    To: Ian Kent <raven@themaw.net>
    Date:	Mon, 21 Feb 2005 00:27:30 -0500
    
    
    

    On Mon, 21 Feb 2005 12:57:22 +0800, Ian Kent said:

    > This is the first time I've heard this and the first time I wrote a Unix
    > daemon was fifteen years ago.
    >
    > As far as I'm concerned redirecting stdin, stdout and stderr to the null
    > device, then closing it and setting the process to a be the group leader
    > (as autofs does) should be all that's needed to daemonize a process.
    >
    > So are we saying that we don't trust the kernel to reliably duplicate the
    > state of file handles when we fork?

    No, you have it 180 degrees off. ;)

    We *do* trust the kernel to reliably duplicate the state of file handles.
    So if we're about to do the whole double-fork thing and all that, we want to
    loop around and close all the file descriptors we don't want leaking to
    the double-forked daemon. Yes, we do something reasonable with fd 0,1,2 -
    but we probably also want to do something with that unclosed fd 3 that's still
    open on /etc/mydaemon.cf, and any other file descriptors we've left dangling
    in the breeze after initialization.

    And yes, this sort of error happens in Real Live - I need to go and figure out
    why the /sbin/lvm.static on my initrd is throwing 'File descriptor 3 left open'
    messages...

    
    

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/



  • Next message: Miles Bader: "Re: [darcs-users] Re: [BK] upgrade will be needed"

    Relevant Pages

    • ADD: Urgent: warning: cannot open /etc/hosts.allow: Too many open files
      ... The problem is that if I only stop/start the daemon, ... The problem is that if the reboot will effectivelly solve the problem. ... > Did you stop/start Ldap after having changed files descriptors limit? ... >>the problem is that the file descriptors of the system is very low ...
      (SunManagers)
    • SUMMARY: Urgent: warning: cannot open /etc/hosts.allow: Too many open files
      ... thanks to Antonia Gomez, Darren Dunham, Bernd Schemmer and Yann Geneste), I ... >frequently the ldap daemon stops to work. ... >the problem is that the file descriptors of the system is very low ... I was used the 'plimit' command to view the information of my slapd ...
      (SunManagers)
    • Re: Really closing stdout (was: "fork and exit" needed?)
      ... If you explicitly want to leave file descriptors 0-2 present ... Establish new open descriptors for stdin, stdout and stderr. ... any other combination that makes sense for your particular daemon. ...
      (comp.lang.python)
    • Re: netbsds daemon(3) fixes.
      ... And whether or not to merge the fixes in? ... daemon() can close innocent file descriptors, ...
      (FreeBSD-Security)
    • Re: GFS, whats remainingh
      ... > Urk, so you imprinted on the clunkiest, most pathetically limited dlm feature ... > have a daemon that sends your values over a socket? ... clunkiest code out there? ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)