subprocessについて
概要
- 標準出力に入出力するインターフェース
- linuxでは
fd(file descriptor)を用いてやり取りする
pythonでの例
from subprocess import PIPE
from subprocess import Popen
with Popen(["cat"], stdin=PIPE, stdout=PIPE) as proc:
proc.stdin.write(b"something input\n")
proc.stdin.close()
print(proc.stdout.read())
output
b'something input\n'
- pythonでは高機能なsubprocessのラッパーである
Popenが用意されている catを起動して、something inputのバイナリ列を書き込むcatから出力された内容を読み込む- 他の機能は公式を参照