From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 23 08:56:42 2007 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40B6116A417 for ; Mon, 23 Jul 2007 08:56:42 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout1.cac.washington.edu (mxout1.cac.washington.edu [140.142.32.134]) by mx1.freebsd.org (Postfix) with ESMTP id 19BB813C428 for ; Mon, 23 Jul 2007 08:56:42 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.32.139]) by mxout1.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW07.06) with ESMTP id l6N8udAx031329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Jul 2007 01:56:39 -0700 X-Auth-Received: from [192.168.10.45] (c-24-10-12-194.hsd1.ca.comcast.net [24.10.12.194]) (authenticated authid=youshi10) by smtp.washington.edu (8.13.7+UW06.06/8.13.7+UW07.03) with ESMTP id l6N8uc38002527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 23 Jul 2007 01:56:38 -0700 Message-ID: <46A46D44.9050504@u.washington.edu> Date: Mon, 23 Jul 2007 01:56:36 -0700 From: Garrett Cooper User-Agent: Thunderbird 2.0.0.5 (Windows/20070716) MIME-Version: 1.0 To: Jose-Marcio.Martins@ensmp.fr References: <46A46910.9080901@u.washington.edu> <46A4699C.5080906@u.washington.edu> <46A46A40.1080004@fs.ei.tum.de> <46A46CE2.4060607@ensmp.fr> In-Reply-To: <46A46CE2.4060607@ensmp.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version: 5.3.2.304607, Antispam-Engine: 2.5.1.298604, Antispam-Data: 2007.7.23.13736 X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' Cc: hackers@freebsd.org Subject: Re: How do I daemonize a process? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jul 2007 08:56:42 -0000 Jose-Marcio Martins da Cruz wrote: > Simon 'corecode' Schubert wrote: >> Garrett Cooper wrote: >>> 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? > > >> >> I suggest daemon(3) if it doesn't have to be portable. > > Or something like this, if it has to be portable or if you don't want > to modify C code : > > nohup /pathto/c-application & > > You'll eventually need to add things like redirect stdout to /dev/null... > > Ok, many thanks for the suggestions all :). I'm more than happy not to do the double fork(2) solution =\.. -Garrett