def popen_filtered(name, args, cwd=None, env=None, redirect_output=True,
                   shell=False):
  if shell and type(args) == list:
    args = ' '.join(args)
  try:
    # note: the preexec_fn below makes the process its own session leader.
    # This means that a CTRL-C on the shell will not be passed on to the process,
    # which enables us to jump between Fuzzing/Replay and Interactive mode.
    cmd = subprocess.Popen(args, stdout=subprocess.PIPE, shell=shell,
                           stderr=subprocess.PIPE, stdin=sys.stdin, cwd=cwd, env=env,
                           preexec_fn=lambda: os.setsid())
  except OSError as e:
    raise OSError("Error launching %s in directory %s: %s (error %d)" % (args, cwd, e.strerror, e.errno))
  if redirect_output:
    cmd._stdout_thread = _prefix_thread(cmd.stdout, partial(color_normal, label=name))
    cmd._stderr_thread = _prefix_thread(cmd.stderr, partial(color_error, label=name))
  return cmd
dataset/ETHPy150Open ucb-sts/sts/sts/util/procutils.py/popen_filtered/original