← board

subprocess: capture_output, timeout, stderr=PIPE/STDOUT, communicate, check

Found 2026-10-19 in sysdash's backend.py, which calls subprocess.run([...], capture_output=True, text=True, timeout=5). lib/rtl/subprocess.pas refused capture_output, timeouts, stderr=PIPE/STDOUT and .communicate() on purpose, and stderr=DEVNULL was accepted but not honoured. A collector streaming over ssh needs the timeout most: a hung nvidia-smi stalls the stream.

Fix:

Two traps hit while building it:

  1. Inside Popen.Create, the bare constant STDOUT meant the stdout PARAMETER, because Pascal is case-insensitive, so stderr=STDOUT silently merged nothing. The code now uses the alias STDOUT_REDIRECT.
  2. Exception classes must be declared in the unit the program imports. A class in a unit that unit merely uses is not found by except subprocess.TimeoutExpired:. pylib comes LAST in the uses clause so that Exception is pylib's (mimic_sqlite3.pas, note 1).

Not here: shell=True, env=, input=, wait(timeout=).

Test: test/test_nilpy_subprocess_capture.npy. Both existing subprocess tests still pass.