From owner-freebsd-hackers Fri Feb 15 20:20:16 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from rwcrmhc54.attbi.com (rwcrmhc54.attbi.com [216.148.227.87]) by hub.freebsd.org (Postfix) with ESMTP id 0867F37B405 for ; Fri, 15 Feb 2002 20:20:10 -0800 (PST) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc54.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020216042009.XNQZ1214.rwcrmhc54.attbi.com@InterJet.elischer.org>; Sat, 16 Feb 2002 04:20:09 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id UAA39554; Fri, 15 Feb 2002 20:14:51 -0800 (PST) Date: Fri, 15 Feb 2002 20:14:50 -0800 (PST) From: Julian Elischer To: Magdalinin Kirill Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: a daemon C skeleton In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG try .... daemon(....args..); ..... (man 3 daemon) On Fri, 15 Feb 2002, Magdalinin Kirill wrote: > Hello, > > can anyone, please, point out a C skeleton for FreeBSD daemon. > Is the following simple example correct for FreeBSD? > > if (getppid() != 1) > { > signal(SIGTTOU, SIG_IGN); > signal(SIGTTIN, SIG_IGN); > signal(SIGTSTP, SIG_IGN); > > if (fork() != 0) > exit(0); > > setsid(); > } > > getrlimit(RLIMIT_NOFILE, &flim); > for (fd = 0; fd < flim.rlim_max; fd++) > close(fd); > > chdir("/"); > > ..... > > > > thanks in advance, > > Kirill Magdalinin > bsdforumen@hotmail.com > > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message