'Spawn a subprocess to log all input to the logging module with the
current settings, and direct output to it.'

def _spawn_logging_subprocess(self):

    (read_end, write_end) = os.pipe()
    pid = os.fork()
    if pid:
        os.close(read_end)
        os.dup2(write_end, self._fd)
        os.close(write_end)
        return pid
    else:
        try:
            os.close(write_end)
            os.close(1)
            os.close(2)
            self._run_logging_subprocess(read_end)
        except Exception:
            try:
                logging.exception('Logging    subprocess    died:')
            finally:
                os._exit(1)
