I am trying to understand how can I make my program a daemon.So some things which I came across are In general, a program performs the following steps to become a daemon: <
If you are looking for a clean approach please consider using standard api- int daemon(int nochdir, int noclose);
. Man page pretty simple and self explanatory. man page. A well tested api far outweigh our own implementation interms of portability and stability.
In Linux, it can be easily done using:
int main(int argc, char* argv[])
{
daemon(0,0);
while(1)
{
sleep(10)
/*do something*/
}
return 0;
}