Outdated subprocess module API High

Using outdated multiprocessing API calls to start and communicate with processes, is not recommended. The subprocess module can be used instead.

Detector ID
python/subprocess-correct-api@v1.0
Category
Common Weakness Enumeration (CWE) external icon
-

Noncompliant example

1def subprocess_call_noncompliant():
2    import subprocess
3    with open("~/output.txt", "w") as f:
4        # Noncompliant: uses 'subprocess.call' with
5        # 'stdout = PIPE' or 'stderr = PIPE'.
6        subprocess.call("~/test.sh", stdout=subprocess.PIPE)

Compliant example

1def subprocess_call_compliant():
2    import subprocess
3    with open("~/output.txt", "w") as f:
4        # Compliant: uses 'subprocess.call' without
5        # 'stdout = PIPE' or 'stderr = PIPE'.
6        subprocess.call("~/test.sh", stdout=f)