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

There are many examples of demon implementations on the net. Most of the ones I saw do not use the daemon (3) function to run the program in the background. Is it just a matter of taste, ignorance, or is there a good reason to write my own daemonize function? Is there a drawback to using the daemon (3)? It's not safe?

+3
source share
4 answers

The daemon () function of BSD is very limited and requires misuse. Only very few demons can use this feature correctly.

systemd man , SysV :

http://0pointer.de/public/systemd-man/daemon.html

+3

daemon() Unix, "" . , , , daemon().

+5

POSIX daemon. . , , , .

+3

- daemon(), . , ; - /dev/null. , stderr , stdin stdout /dev/null, , daemon() , , , .

daemon() ; fork() setsid() ( Linux, MacOS SIGHUP daemon()). - :

+2
source

Source: https://habr.com/ru/post/1764945/


All Articles