1.\" Copyright (c) 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" %sccs.include.redist.man% 5.\" 6.\" @(#)daemon.3 8.1 (Berkeley) 06/09/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 29.Fa noclose 30is non-zero, 31.Fn daemon 32will redirect standard input, standard output and standard error 33to ``/dev/null''. 34.Sh ERRORS 35The function 36.Fn daemon 37may fail and set 38.Va errno 39for any of the errors specified for the library functions 40.Xr fork 2 41and 42.Xr setsid 2 . 43.Sh SEE ALSO 44.Xr setsid 2 45.Sh HISTORY 46The 47.Fn daemon 48function first appeared in 4.4BSD. 49