summaryrefslogtreecommitdiffstats
path: root/08-exit-codes.txt
blob: df3fb9b78668ce13b11a8845c323f4af507f0718 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Model situation:
complex bash script has failed with some non-obvious exit code while
the subsequent runs are as expected (i.e., intermittent error or
something of that kind)

Solution #1: quick web search
Solution #2: study all the functions and program invocations on all/guessed
             code paths wrt. their return codes (not always properly
             documented!) + add some bash runtime considerations
Solution #3: grep this document and pray it will help you :)


2
* bash:*
  - incorrect use of builtins
    $ [
    bash: [: missing `]'

126
* bash
  - command found but not executable
    $ /etc
    bash: /etc: Is a directory

127
* general
  - cannot dynamically link in run-time (TODO: who is responsible here, exactly?):
    $ ./testfoo
    ./testfoo: error while loading shared libraries: libgetfoo.so: cannot open shared object file: No such file or directory
* bash
  - unknown function/command
    $ foo
    bash: foo: command not found
* bash:wait
  - waiting for nonexistent process/job
    $ /bin/true & { sleep 1; wait $(($! - 1));}
    bash: wait: pid 2864 is not a child of this shell

254
* bash
  - when cannot fork so as to perform the command due to hitting number
    of user processes limit, it will (IIUIC, first it will keep looping
    over emitting "fork: retry: No child processes" and "fork: Resource
    temporarily unavailable" messages, until it is eventually able to do
    a fork to get outside of this loop, and then it will...) will
    yield such exit status:
    $ ulimit -u $(($(ps --no-headers -mu $(id -u) | wc -l) + 1))
    $ sleep 1 & sleep 1
    bash: fork: retry: No child processes
    bash: fork: retry: No child processes
    bash: fork: retry: No child processes
    bash: fork: retry: No child processes
    bash: fork: Resource temporarily unavailable
    [...]
    bash: fork: retry: No child processes
    bash: fork: retry: No child processes
    bash: fork: retry: No child processes
    bash: fork: retry: No child processes
  - see also [1]
  - bash code perspective:
    jobs.c:
      last_command_exit_value = EX_NOEXEC;
      /** exit_value = EX_NOEXEC = 126 **/
      throw_to_top_level ();    /* Reset signals, etc. */
      /** exit_value = 126 | 128 = 254 **/


[1] http://unix.stackexchange.com/questions/19113/fork-negative-return-value/19119#19119