[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS, Python's subprocess.Ppen() and STDOUT redirection

From: Michał Górny
Subject: CVS, Python's subprocess.Ppen() and STDOUT redirection
Date: Tue, 24 Aug 2010 22:54:52 +0200


I'm trying to get CVS support integrated into my Python script,
and I ran into a serious problem.

The Python script calls various VCSes using subprocess.Popen(). As
STDOUT of the script is supposed to be piped onto another program, I
redirect STDOUT to STDERR when calling the VCSes.

While for most VCSes that works fine, CVS has real problems with
the way Python redirects fds. The 'cvs login' command only outputs
the 'Logging in...' message, and 'cvs up' doesn't output anything. Even
if I use '-tttt', they don't show any output and return with exit code

I guess that's because CVS is trying to close STDOUT. In this
particular case, this causes it to close STDERR as well. I've
reproduced the problem with a simple test program:

#include <stdio.h>

int main(void) {
    fprintf(stdout, "foo\n");
    fprintf(stderr, "bar\n");

As I've expected, calling it with Popen(..., stdout=sys.stderr) causes
only 'foo' to be output.

I'm not sure if the problem is rather in CVS or Python, but I
personally think it's not a good idea to close STDOUT anyway.

Best regards,
Michał Górny


Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]