Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jul 2007 10:48:10 +0200
From:      Maxime Henrion <mux@FreeBSD.org>
To:        Garrett Cooper <youshi10@u.washington.edu>
Cc:        hackers@freebsd.org
Subject:   Re: How do I daemonize a process?
Message-ID:  <20070723084810.GE44455@elvis.mu.org>
In-Reply-To: <46A46910.9080901@u.washington.edu>
References:  <46A46910.9080901@u.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Garrett Cooper wrote:
>    As the subject suggests I'm trying to determine how I can daemonize 
> a C process, outside of using the rc infrastructure, so that it won't 
> exit when the TTY exists. Does anyone know any quick references or examples?
> Thanks,
> -Garrett

The proper way to do this is to use the setsid() function.  If it
is somehow not available on one of your target system, some people
use a hack which consists in calling fork() two times to daemonize
the process; that is supposed to work too.

Cheers,
Maxime



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070723084810.GE44455>