From owner-freebsd-hackers Fri Feb 15 0:58:45 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from birch.ripe.net (birch.ripe.net [193.0.1.96]) by hub.freebsd.org (Postfix) with ESMTP id 1372937B417 for ; Fri, 15 Feb 2002 00:58:40 -0800 (PST) Received: from laptop.6bone.nl (penguin.ripe.net [193.0.1.232]) by birch.ripe.net (8.11.6/8.11.6) with SMTP id g1F8waa27957; Fri, 15 Feb 2002 09:58:36 +0100 Received: (nullmailer pid 4972 invoked by uid 1000); Fri, 15 Feb 2002 08:58:35 -0000 Date: Fri, 15 Feb 2002 09:58:35 +0100 From: Mark Santcroos To: Magdalinin Kirill Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: a daemon C skeleton Message-ID: <20020215095835.A57920@laptop.6bone.nl> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from bsdforumen@hotmail.com on Fri, Feb 15, 2002 at 11:52:22AM +0300 X-Handles: MS6-6BONE, MS18417-RIPE 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 man 3 daemon On Fri, Feb 15, 2002 at 11:52:22AM +0300, 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 -- Mark Santcroos RIPE Network Coordination Centre http://www.ripe.net/home/mark/ New Projects Group/TTM To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message