Skip to content

Audit · 7 min

The helper that works until the output grows

Generated when asked to run a command and capture its output.

python
import subprocess

def run(cmd):
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    p.wait()
    return p.stdout.read(), p.stderr.read()

Before it runs

When does this hang?

Nothing has run

Read it first. Answer, and the same calls run here.