[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] Fix bug #709 by daemonizing blktapctrl and closing stdin, stdout and stderr




On Aug 1, 2006, at 6:33 AM, Keir Fraser wrote:


On 1 Aug 2006, at 11:27, Muli Ben-Yehuda wrote:

Does it make sense for this to be folded into a common utility
library?

Anil Madhavapeddy pointed out it already is: man 3 daemon.

Cool! I wasn't aware of it. How portable is it? how portable should
the tools be in general?

Ah, that might be a concern, for the Solaris port in particular. daemon() is I think a BSD function ported to Linux. It's not POSIX. Keeping the existing code is uglier but probably more portable.

IMHO, it is better to use a system provided feature that has a large peer review audience than roll our own. There are plenty of portable projects that use this method and fall back to a compatibility library for daemon(3), the OpenSSH project in particular has had to deal with it, I suggest if Solaris needs to borrow any code they borrow it from sshd.

Please also remember that daemons, since they are typically started from the craziest init scripts, should close _all_ file descriptors not explicitly opened or required by the daemon.

    for (i = 0; i < sysconf(_SC_OPEN_MAX); i++) {
        if (i not explicit)
           close(i);
    }

-JX

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.