Understanding Daemon Process
A daemon process is a process which runs in background and has no controlling terminal. Normally daemon process are running on boot, running as root or other system user and handle system tasks.
The requirement to run a daemon it must run as a child of init process and not connected to a terminal.
How to create a daemon
Call fork() off the parent process. Call exit() on parent process Call setsid() to give new process group and session ID (SID) to become child process as a session leader. Call signal() to ignore any signal sent from child to parent Call again fork() to check that the daemon is not a session leader, which prevents it from acquiring a controlling terminal. Call umask(0); Set new file permissions Call chdir() to change the current working directory Close file descriptors. Reopen all file descriptor and redirect them to /dev/null, call open() /dev/null for stdin to return a file descriptor and the dublicate with dup() for stdout and stderr. Call daemon code.
Other way on Linux systems you can call daemon() to create it.
https://stackoverflow.com/questions/17954432/creating-a-daemon-in-linux/17955149#17955149 https://linux.die.net/man/2/setsid http://man7.org/linux/man-pages/man2/umask.2.html http://man7.org/linux/man-pages/man3/sysconf.3.html http://man7.org/linux/man-pages/man2/open.2.html http://man7.org/linux/man-pages/man2/dup.2.html