BSD daemon()

There is a function called daemon() in /usr/lib/libbsd.a. Use of the BSD stuff is not really encouraged, as it is not POSIX conformant and therefore could cause portability issues. However, the call is described here for completeness. I found it while searching through the libc source. The function takes two integer arguments—the first specifies whether to change the operating directory to / or not (zero implies change, non-zero implies no change); the second argument specifies whether to close open file descriptors or not (zero implies close, non-zero implies don't close).

libbsd.a is a non-sharable library that gets linked in only if the user specifies it at link time with the -lbsd flag.

There is no header file containing a prototype for this function, but its prototype is as follows:

int daemon(int noChangeDir, int noClose);