The second group of four allows us to create, verify, read, and delete a semaphore. With the raising of a semaphore, the rest of the system can know that our daemon is 'alive'. This is not as important for this daemon, but the need will be great in parallel synchronization. And the last group of four functions collectively will be the mechanism to keep a record of the program crashing, and recovery attempt. Function names should always be close in description to the functionality contained within.
Lets take a look at the meat of the code.
I will attempt to state the core functionality of the functions, and the code will follow. They all key off from the name of the executable. It was included because you may need it there in the development stage of writing your own daemon. You do need it later on. This daemon then closes all 'standard devices' because daemons have no use for such things.