<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def daemon_spawn(self, pre_fork_opts=None, post_fork_parent_opts=None, post_fork_child_opts=None):
 """Perform a single-fork to run a subprocess and write the child pid file. Use this if your post_fork_child block invokes a subprocess via subprocess.Popen(). In this case, a second fork such as used in daemonize() is extraneous given that Popen() also forks. Using this daemonization method vs daemonize() leaves the responsibility of writing the pid to the caller to allow for library-agnostic flexibility in subprocess execution. """

    self.purge_metadata()
    self.pre_fork(**pre_fork_opts or {})
    pid = os.fork()
    if pid == 0:
      try:
        os.setsid()
        os.chdir(self._buildroot)
        self.post_fork_child(**post_fork_child_opts or {})
      except Exception:
        logger.critical(traceback.format_exc())
      finally:
        os._exit(0)
    else:
      try:
        self.post_fork_parent(**post_fork_parent_opts or {})
      except Exception:
        logger.critical(traceback.format_exc())