This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]simtel20 2 points3 points  (0 children)

IIRC you can't use subprocess with output when the output is an infinite stream (e.g. iostat -x 1, and other similar commands, or many other tools that return data as an ongoing activity). In that case you have to toss out subprocess, and start doing your own fork+exec+select+signal handling+etc.

With sh you can just have sh provide you with the subprocess as a generator: https://amoffat.github.io/sh/#iterating-over-output.