The subprocess documentation has both a returncode and a stderr value when in the tuple returned by .communicate(). If there is a value assigned to stderr, is this classed as the program successfully run and finished (and hence returncode will be 0) or not (and then the value of returncode will be greater than 0)?
- Why the downvotes? I'd be really interested why 2 people think that 'This question does not show any research effort; it is unclear or not useful'ChrisW– ChrisW2012-12-04 15:46:14 +00:00Commented Dec 4, 2012 at 15:46
- 1Frustrating when people won't face up to their actions...ChrisW– ChrisW2012-12-04 17:04:36 +00:00Commented Dec 4, 2012 at 17:04
2 Answers
stderr refers to the standard error stream of the process, as explained here: http://en.wikipedia.org/wiki/Stderr#Standard_error_.28stderr.29
You can write messages to that for debug purposes, and still have an exit code of zero.
Comments
Popen.communicate will return a tuple containing the data that was writte to stdout and stderr (or None for each value if nothing was written).
After communicate returns you can inspect the returncode attribute on your Popen instance to get the exit status of the process, if this differs from 0 it is generally an indication that an error occurred.