0

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)?

2
  • 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' Commented Dec 4, 2012 at 15:46
  • 1
    Frustrating when people won't face up to their actions... Commented Dec 4, 2012 at 17:04

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

-1

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.

2 Comments

Yes - I understand this. I didn't know if the exit code had to be >0 if stderr was not null
No, the returncode does not have to be >0 of stderr is not None, any process can decide to write something to stderr.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.