Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

37. Daemons > Guidelines for Writing Daemons

Guidelines for Writing Daemons

As previously noted, a daemon typically terminates only when the system shuts down. Many standard daemons are stopped by application-specific scripts executed during system shutdown. Those daemons that are not terminated in this fashion will receive a SIGTERM signal, which the init process sends to all of its children during system shutdown. By default, SIGTERM terminates a process. If the daemon needs to perform any cleanup before terminating, it should do so by establishing a handler for this signal. This handler must be designed to perform such cleanup quickly, since init follows up the SIGTERM signal with a SIGKILL signal after 5 seconds. (This doesn’t mean that the daemon can perform 5 seconds’ worth of CPU work; init signals all of the processes on the system at the same time, and they may all be attempting to clean up within that 5 seconds.)


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint