Capture C-level stdout/stderr pipes in Python via os.dup2. Comments from semarie@ OK danj@ OK and tweaks jca@