Meaning of exit status 1 returned by linux command
Asked Answered
B

3

42

What is meaning of exit status 1 returned by linux command? Like 127 exit status indicates "command not found".

I have visited http://linux.die.net/abs-guide/exitcodes.html page, does it mean exit status 1 does not have particular special meaning?

Bergman answered 7/1, 2014 at 7:1 Comment(2)
The ABS link is confused. These exit codes are not "reserved" and the table is a happy drunk mixture of Bash-internal usage, general Unix conventions, and the author's loud opinion.Hewett
See also now #36531196Hewett
H
46

The only general convention is that a zero exit status signifies success, whereas any non-zero exit status is a failure. Different non-zero values may indicate the reason for the exit status, usually documented for the particular program.

C's <stdlib.h> include file defines two constants:

  1. EXIT_FAILURE (1)
  2. EXIT_SUCCESS (0)

"man-pages(7)" suggests to document the meaning of the exit status in section EXIT STATUS.

Many -- but certainly not all -- command-line tools return exit code 1 for syntax error, i.e. you had too few arguments or an invalid option.

Many -- but, alas, not all -- command-line tools have a manual page. By convention, it should document the exit codes of the program, but many do not.

Hewett answered 7/1, 2014 at 7:37 Comment(0)
O
18

You can see the value of the exit status using man.

Giving an example below:

man ls

Now search for string exit

Adding screen shot below:

enter image description here

Omdurman answered 7/1, 2014 at 9:46 Comment(2)
As tripleee posted not all command's man page documented exit codes. I am facing exit status related problem for command msgfmt, it's man page does not documented about exit codes.Bergman
msgfmt.c seems to use the generic EXIT_FAILURE in basically every error situation. There would be an error message telling you what went wrong, though.Hewett
D
0

Exit Code 1 means that a container terminated, typically due to an application error or an invalid reference. A non-zero (1-255) exit status indicates failure.

For example, if a Java library is running , and the library throws a compiler error, the container might terminate with Exit Code 1.

A command which exits with a zero (0) exit status means it succeeded.

Disable answered 6/5, 2023 at 5:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.