Daemonizing Processes and System Log
2011/09/30 Leave a comment
If you write software for embedded applications, sooner or later you will end up writing a daemon.
In my work I see many embedded applications, but very often the programmer write and debug all the program in foreground, and then forgets to implement a simple daemonize function.
The consequence is that when the application is started from the init scripts instead that from a command shell, it locks up the entire boot sequence of the system.
Also, when writing a background application, all the messages should be redirected to the system log… don’t reinvent the wheel rewriting a new logging system!
Here I’ll show a sample daemonize() function, and how to use the syslog() library function.