code: def fork():
      """fork() -> (pid, master_fd)
      Fork and make the child a session leader with a controlling terminal.
      """
  
      try:
          pid, fd = os.forkpty()
      except (AttributeError, OSError):
          pass
      else:
          if pid == CHILD:
              try:
                  os.setsid()
              except OSError:
                  # os.forkpty() already set us session leader
                  pass
          return pid, fd
  
      master_fd, slave_fd = openpty()
      pid = os.fork()
      if pid == CHILD:
          # Establish a new session.
          os.setsid()
          os.close(master_fd)
  
          # Slave becomes stdin/stdout/stderr of child.
          os.dup2(slave_fd, STDIN_FILENO)
          os.dup2(slave_fd, STDOUT_FILENO)
          os.dup2(slave_fd, STDERR_FILENO)
          if slave_fd > STDERR_FILENO:
              os.close(slave_fd)
  
          # Explicitly open the tty to make it become a controlling tty.
          tmp_fd = os.open(os.ttyname(STDOUT_FILENO), os.O_RDWR)
          os.close(tmp_fd)
      else:
          os.close(slave_fd)
  
      # Parent and child process.
      return pid, master_fd
  
file_path: catboost/contrib/tools/python3/src/Lib/pty.py
imports: from select import select
  import os
  import sys
  import tty
  from os import close, waitpid
  from tty import setraw, tcgetattr, tcsetattr
label_desc: Use image node_id 5 for calling a global function with example usage: fork() and returns: pid,  master_fd, pid,  fd