Re: a daemon C skeleton

2002-02-15 Thread Julian Elischer

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
> [EMAIL PROTECTED]
> 
> _
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
> 
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
> 


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: a daemon C skeleton

2002-02-15 Thread Maxim Konovalov

On 11:52+0300, Feb 15, 2002, Magdalinin Kirill wrote:

> Hello,
>
> can anyone, please, point out a C skeleton for FreeBSD daemon.

Take a look at src/lib/libc/gen/daemon.c, man 3 daemon

HTH,

-- 
Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer
phone: +7 (095) 796-9079, mailto:[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: a daemon C skeleton

2002-02-15 Thread Mark Santcroos

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
> [EMAIL PROTECTED]
> 
> _
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
> 
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> 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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



a daemon C skeleton

2002-02-15 Thread Magdalinin Kirill

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
[EMAIL PROTECTED]

_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message