24

I've seen the usage of exit status 3 in several python scripts that restart processes. As far as I know the convention is only about 0 and "not 0" on Unix/Linux.

Is there a convention defining other values like 3.

SilentGhost
  • 307,395
  • 66
  • 306
  • 293
deamon
  • 89,107
  • 111
  • 320
  • 448
  • @daemon: If there was a convention, it still doesn't answer the question "what does 3 mean **in this case** "? A convention is not a law. And the specific script you're working with could fail to adhere to the convention. – S.Lott Oct 22 '10 at 12:35
  • 3
    @S.Lott - I think what's he's asking is, "I know that 0 means no error, and non-zero means an error, but is there some convention out there in Python/Linux/Unix land that gives special meaning to 3?" – J. Polfer Oct 22 '10 at 17:34
  • @sheepsimulator: What I'm saying is that even if there is a convention, that information is unhelpful. I think the real question is "what does 3 mean **in this case** "? – S.Lott Oct 22 '10 at 17:41

4 Answers4

11

At least in the old days, a return value of 1 generally meant a hard error and value 2 was usually reserved for problems with the command line arguments — it meant that the user had made an error, not the program. But beyond that: no, no convention; and even that slight convention was not universal. Like dashes in front of command-line arguments, which some versions of ps(1) let you omit, return codes were just convention. In general, read the docs (or the source!) to the script you're running and you then have to write error-code checking code to its specific meanings.

Brandon Rhodes
  • 83,755
  • 16
  • 106
  • 147
4

There is no convention for non-zero values, they are commonly used to communicate the reason for termination and it's up to each application to define the mapping of error code and reason. In the case you're linking to you can clearly see a few lines above the check for exit code 3 that it is used to indicate that the code has changed.

Ie in this case this will give the behaviour that the automatic restart is done as long as the reason to terminate was that the code changed and nothing else.

ckk
  • 171
  • 1
  • 4
1

In this case, its unclear. foret's suggestion is one I would totally do if the developer is still around.

The Advanced Bash Scripting Guide lists some common exit codes with special meanings.

J. Polfer
  • 12,251
  • 10
  • 54
  • 83
0

BSD tried to standardize exit codes, but it didn't (hasn't yet?) caught on:

sysexits3

JS.
  • 14,781
  • 13
  • 63
  • 75