What's the difference between calling daemon() and calling fork(), setsid(), fork(), etc.?
问题 I've been looking at creating Unix dæmons, and there seem to be two methods. The long-winded one, which seems to come up when searching is to call fork() , setsid() , fork() again, chdir() to somewhere safe, set umask() and, finally, close() stdin , stdout and stderr . Running man daemon , however, brings up information on a daemon() function, which seems to do all the same stuff as above. Are there any differences between the two approaches or is daemon() just a convenience function that