code: def _fork_process() -> int:
      assert os.name == "posix"
  
      # NOTE: using os._exit instead of sys.exit, because dvc built
      # with PyInstaller has trouble with SystemExit exception and throws
      # errors such as "[26338] Failed to execute script __main__"
      try:
          pid = os.fork()  # type: ignore[attr-defined]
          if pid > 0:
              return pid
      except OSError:
          logger.exception("failed at first fork")
          os._exit(1)
  
      os.setsid()  # type: ignore[attr-defined]
  
      try:
          pid = os.fork()  # type: ignore[attr-defined]
          if pid > 0:
              os._exit(0)
      except OSError:
          logger.exception("failed at second fork")
          os._exit(1)
  
      # disconnect from the terminal
      fd = os.open(os.devnull, os.O_RDWR)
      for fd2 in range(3):
          os.dup2(fd, fd2)
      os.close(fd)
      return pid
  
imports: import inspect
  import logging
  import os
  import subprocess
  import sys
  from contextlib import nullcontext
  from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Sequence, Union
  from dvc.log import logger
  from dvc.env import DVC_DAEMON, DVC_DAEMON_LOGFILE
  from dvc.utils import fix_env, is_binary
  from dvc.utils.collections import ensure_list
label_desc: Use image node_id 4 for calling a global function with example usage: _fork_process() and returns: pid, pid