title: Correct daemon behaviour (from PEP 3143) explained
body: <p>I have some tasks [for my RPi] in Python that involve a lot of <code>sleep</code>ing: do something that takes a second or two or three, then go wait for several minutes or hours. 
  I want to pass control back to the OS (Linux) in that sleep time. For this, I should daemonise those tasks. One way is by using Python's Standard daemon process library.  </p>
  
  <p>But daemons aren't so easy to understand. As per the Rationale paragraph of <a href="http://legacy.python.org/dev/peps/pep-3143/#correct-daemon-behaviour" rel="noreferrer">PEP 3143</a>, a well behaved daemon should do the following. </p>
  
  <ul>
  <li>Close all open file descriptors.</li>
  <li>Change current working directory.</li>
  <li>Reset the file access creation mask.</li>
  <li>Run in the background.</li>
  <li>Disassociate from process group.</li>
  <li>Ignore terminal I/O signals.</li>
  <li>Disassociate from control terminal.</li>
  <li>Don't reacquire a control terminal.</li>
  <li>Correctly handle the following circumstances:
  
  <ul>
  <li>Started by System V init process.</li>
  <li>Daemon termination by SIGTERM signal.</li>
  <li>Children generate SIGCLD signal.</li>
  </ul></li>
  </ul>
  
  <p>For a Linux/Unix novice like me, some of this is hardly an explanation. But I want to know why I do what I do. So what is the rationale behind this rationale? </p>