Using daemon from /etc/init.d/functions

Dave Smith dave at
Fri Mar 30 23:11:45 MDT 2007

Michael Torrie wrote:
> No, indeed the recommended procedure for portably deamonizing a server
> is to use the double fork.  I'm not sure of all the reasons, but it is
> in the examples I've seen and I've used that method myself.

To answer my own question after some research and consulting with local 
experts Byron Clark and Michael Torrie: if I were on a decent linux 
distro, I would use start-stop-daemon, but since most RHEL 3 and 4 
installs don't have it by default, I'm stuck with the daemon() bash 
function, which doesn't do auto-daemonization of executables. I had to 
add a "--daemon" argument to my executable, and use the daemon(int,int) 
function on Linux (#include <unistd.h>) to go into the background. This 
saves me the hassle of all the double fork, setsid(), and close() 
business. Works great.


More information about the PLUG mailing list