xref: /csrg-svn/lib/libc/gen/daemon.3 (revision 59429)
1.\" Copyright (c) 1993 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"	@(#)daemon.3	5.1 (Berkeley) 04/27/93
7.Dd
8.Dt DAEMON 3
9.Os
10.Sh NAME
11.Nm daemon
12.Nd run in the background
13.Sh SYNOPSIS
14.Fn daemon "int nochdir" "int noclose"
15.Sh DESCRIPTION
16.Pp
17The
18.Fn daemon
19function is for programs wishing to detach themselves from the
20controlling terminal and run in the background as system daemons.
21.Pp
22Unless the argument
23.Fa nochdir
24is non-zero,
25.Fn daemon
26changes the current working directory to the root (``/'').
27.Pp
28Unless the argument
29Unless the argument
30.Fa noclose
31is non-zero,
32.Fn daemon
33will redirect standard input, standard output and standard error
34to ``/dev/null''.
35.Sh ERRORS
36The function
37.Fn daemon
38may fail and set
39.Va errno
40for any of the errors specified for the library functions
41.Xr fork 2
42and
43.Xr setsid 2 .
44.Sh SEE ALSO
45.Xr setsid 2
46.Sh HISTORY
47The
48.Fn daemon
49function is
50.Ud .
51