Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Feb 2002 11:52:22 +0300
From:      "Magdalinin Kirill" <bsdforumen@hotmail.com>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   a daemon C skeleton
Message-ID:  <F105Q0tArbDVL7IZQII0001fd3e@hotmail.com>

next in thread | raw e-mail | index | archive | help
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




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