code: def redirect_std():
      
      stdin = sys.stdin
      stdout = sys.stdout
      if not sys.stdin.isatty():
          sys.stdin = open_raw("/dev/tty", "r", 0)
      if not sys.stdout.isatty():
          sys.stdout = open_raw("/dev/tty", "w", 0)
  
      return stdin, stdout
docs: Connect stdin/stdout to controlling terminal even if the scripts input and output
      were redirected. This is useful in utilities based on termenu.