If yes, on which operating system, shell or whatever?
Consider the following java program (I'm using java just as an example, any language would be good for this question, which is more about operation systems):
public class ExitCode {
public static void main(String args[]) {
System.exit(Integer.parseInt(args[0]));
}
}
Running it on Linux and bash, it returns always values less equal 255, e.g. (echo $?
prints the exit code of the previous executed command)
> java ExitCode 2; echo $?
2
> java ExitCode 128; echo $?
128
> java ExitCode 255; echo $?
255
> java ExitCode 256; echo $?
0
> java ExitCode 65536; echo $?
0
EDITED: the (only, so far) answer below fully explain what happens on UNIXes. I'm still wondering about other OSes.