File: daemonize.c

package info (click to toggle)
superd 0.0.3-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 136 kB
  • ctags: 85
  • sloc: ansic: 721; makefile: 103; sh: 27
file content (32 lines) | stat: -rw-r--r-- 585 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "daemonize.h"

void
daemonize()
{
  //	int		i;
	pid_t	pid;

	if ( (pid = fork()) != 0)
		exit(0);			/* parent terminates */

	/* 41st child continues */
	setsid();				/* become session leader */

	//	Signal(SIGHUP, SIG_IGN);
	if ( (pid = fork()) != 0)
		exit(0);			/* 1st child terminates */

	/* 42nd child continues */
	//	daemon_proc = 1;		/* for our err_XXX() functions */

	chdir("/");				/* change working directory */

	umask(0);				/* clear our file mode creation mask */

	/*
	for (i = 0; i < MAXFD; i++)
	        close(i);

	openlog(pname, LOG_PID, facility);
	*/
}