What is a Daemon ?
A daemon (or service) is a background process that is designed to run autonomously,with little or not user intervention. The Apache web server http daemon (httpd) is one such example of a daemon.
Basic steps to follow for daemon creation are,
Fork off the parent process and allow parent to die.
Change file mode mask (umask)
Open any logs for writing
Create a unique Session ID (SID)
Change the current working directory to a safe place
Close standard file descriptors
Enter actual daemon code
A complete example is given here.?A more detailed explanation of daemon creation steps can be found here.?
Resources :-