Python subprocess.Popen pipe custom fd

I currently have this code that pipe stdout or stderr following the context:

def execteInstruction(cmd, outputNumber):
  do_stdout = DEVNULL
  do_stderr = DEVNULL
  if outputNumber != 2:
    do_stdout = subprocess.PIPE
  else:
    do_stderr = subprocess.PIPE
  return subprocess.Popen(cmd, shell=True, stderr=do_stderr, stdout=do_stdout)

And then I read the result with communicate() . This works perfectly well except that I need to read a custom fd because I'm using subprocess to run a command that output on the file descriptor 26.

I have seen code that write to another fd than stdout or stderr, but none that read from a custom fd. So how can I pipe a custom fd from subprocess.Popen ?

链接地址: http://www.djcxy.com/p/77120.html

上一篇: Python监视子进程的stderr和stdout

下一篇: Python子进程.Popen管道自定义fd