| 1 |
/***************************************************************************
|
| 2 |
bbsd.c - description
|
| 3 |
-------------------
|
| 4 |
begin : Mon Oct 18 2004
|
| 5 |
copyright : (C) 2004 by Leaflet
|
| 6 |
email : leaflet@leafok.com
|
| 7 |
***************************************************************************/
|
| 8 |
|
| 9 |
/***************************************************************************
|
| 10 |
* *
|
| 11 |
* This program is free software; you can redistribute it and/or modify *
|
| 12 |
* it under the terms of the GNU General Public License as published by *
|
| 13 |
* the Free Software Foundation; either version 2 of the License, or *
|
| 14 |
* (at your option) any later version. *
|
| 15 |
* *
|
| 16 |
***************************************************************************/
|
| 17 |
|
| 18 |
#include "common.h"
|
| 19 |
#include <signal.h>
|
| 20 |
|
| 21 |
void
|
| 22 |
init_daemon (void)
|
| 23 |
{
|
| 24 |
int pid;
|
| 25 |
int i;
|
| 26 |
|
| 27 |
if (pid = fork ())
|
| 28 |
exit (0);
|
| 29 |
else if (pid < 0)
|
| 30 |
exit (1);
|
| 31 |
|
| 32 |
setsid ();
|
| 33 |
|
| 34 |
if (pid = fork ())
|
| 35 |
exit (0);
|
| 36 |
else if (pid < 0)
|
| 37 |
exit (1);
|
| 38 |
|
| 39 |
for (i = 0; i < NOFILE; ++i)
|
| 40 |
close (i);
|
| 41 |
chdir ("/tmp");
|
| 42 |
umask (0);
|
| 43 |
|
| 44 |
signal(SIGCHLD,SIG_IGN);
|
| 45 |
|
| 46 |
return;
|
| 47 |
}
|