A Linux Daemon and the STDIN/STDOUT

前端 未结 6 1285
别跟我提以往
别跟我提以往 2021-02-14 23:32

I am working on a linux daemon and having some issues with the stdin/stdout. Normally because of the nature of a daemon you do not have any stdin or stdout. However, I do have a

6条回答
  •  悲哀的现实
    2021-02-15 00:08

    If you want to run your program detached, use the shell: (setsid &). Do not fork() inside your program, which will cause sysadmin nightmare.

    Don't use syslog() nor redirect stdout or stderr.

    Better yet, use a daemon manager such as daemon tools, runit, OpenRC and systemd, to daemonize your program for you.

提交回复
热议问题