Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a good reason to write my own daemonize function instead of using daemon(3)?

There are a lot of example implementations of daemons on the net. Most that I saw do not use the daemon(3) function to run the program in the background. Is that just a matter of taste, ignorance, or is there a good reason to write my own daemonize function? Is there a specific disadvantage in using daemon(3)? Is it insecure?

like image 668
Jan Deinhard Avatar asked Dec 12 '22 19:12

Jan Deinhard


1 Answers

The daemon() function was not historically available in all flavors of Unix, so a lot of "portable" code doesn't use it. There's really no reason to roll your own recipe as long as all the target platforms you care about have daemon().

like image 186
Kaelin Colclasure Avatar answered Dec 28 '22 20:12

Kaelin Colclasure