blob: 73518fccd37737491e10b119656809e674ceaedb [file] [log] [blame]
Dennis Dmitrieve56c8b92017-06-16 01:53:16 +03001# Copyright 2016 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import enum
16
17
18@enum.unique
19class SigNum(enum.IntEnum):
20 SIGHUP = 1 # Hangup (POSIX).
21 SIGINT = 2 # Interrupt (ANSI).
22 SIGQUIT = 3 # Quit (POSIX).
23 SIGILL = 4 # Illegal instruction (ANSI).
24 SIGTRAP = 5 # Trace trap (POSIX).
25 SIGABRT = 6 # Abort (ANSI).
26 SIGBUS = 7 # BUS error (4.2 BSD).
27 SIGFPE = 8 # Floating-point exception (ANSI).
28 SIGKILL = 9 # Kill, unblockable (POSIX).
29 SIGUSR1 = 10 # User-defined signal 1 (POSIX).
30 SIGSEGV = 11 # Segmentation violation (ANSI).
31 SIGUSR2 = 12 # User-defined signal 2 (POSIX).
32 SIGPIPE = 13 # Broken pipe (POSIX).
33 SIGALRM = 14 # Alarm clock (POSIX).
34 SIGTERM = 15 # Termination (ANSI).
35 SIGSTKFLT = 16 # Stack fault.
36 SIGCHLD = 17 # Child status has changed (POSIX).
37 SIGCONT = 18 # Continue (POSIX).
38 SIGSTOP = 19 # Stop, unblockable (POSIX).
39 SIGTSTP = 20 # Keyboard stop (POSIX).
40 SIGTTIN = 21 # Background read from tty (POSIX).
41 SIGTTOU = 22 # Background write to tty (POSIX).
42 SIGURG = 23 # Urgent condition on socket (4.2 BSD).
43 SIGXCPU = 24 # CPU limit exceeded (4.2 BSD).
44 SIGXFSZ = 25 # File size limit exceeded (4.2 BSD).
45 SIGVTALRM = 26 # Virtual alarm clock (4.2 BSD).
46 SIGPROF = 27 # Profiling alarm clock (4.2 BSD).
47 SIGWINCH = 28 # Window size change (4.3 BSD, Sun).
48 SIGPOLL = 29 # Pollable event occurred (System V)
49 SIGPWR = 30 # Power failure restart (System V).
50 SIGSYS = 31 # Bad system call.
51
52 def __str__(self):
53 return "{name}<{value:d}(0x{value:02X})>".format(
54 name=self.name,
55 value=self.value
56 )
57
58
59@enum.unique
60class ExitCodes(enum.IntEnum):
61 EX_OK = 0 # successful termination
62
63 EX_INVALID = 0xDEADBEEF # uint32 debug value. Impossible for POSIX
64
65 EX_ERROR = 1 # general failure
66 EX_BUILTIN = 2 # Misuse of shell builtins (according to Bash)
67
68 EX_USAGE = 64 # command line usage error
69 EX_DATAERR = 65 # data format error
70 EX_NOINPUT = 66 # cannot open input
71 EX_NOUSER = 67 # addressee unknown
72 EX_NOHOST = 68 # host name unknown
73 EX_UNAVAILABLE = 69 # service unavailable
74 EX_SOFTWARE = 70 # internal software error
75 EX_OSERR = 71 # system error (e.g., can't fork)
76 EX_OSFILE = 72 # critical OS file missing
77 EX_CANTCREAT = 73 # can't create (user) output file
78 EX_IOERR = 74 # input/output error
79 EX_TEMPFAIL = 75 # temp failure; user is invited to retry
80 EX_PROTOCOL = 76 # remote error in protocol
81 EX_NOPERM = 77 # permission denied
82 EX_CONFIG = 78 # configuration error
83
84 EX_NOEXEC = 126 # If a command is found but is not executable
85 EX_NOCMD = 127 # If a command is not found
86
87 # Signal exits:
88 EX_SIGHUP = 128 + SigNum.SIGHUP
89 EX_SIGINT = 128 + SigNum.SIGINT
90 EX_SIGQUIT = 128 + SigNum.SIGQUIT
91 EX_SIGILL = 128 + SigNum.SIGILL
92 EX_SIGTRAP = 128 + SigNum.SIGTRAP
93 EX_SIGABRT = 128 + SigNum.SIGABRT
94 EX_SIGBUS = 128 + SigNum.SIGBUS
95 EX_SIGFPE = 128 + SigNum.SIGFPE
96 EX_SIGKILL = 128 + SigNum.SIGKILL
97 EX_SIGUSR1 = 128 + SigNum.SIGUSR1
98 EX_SIGSEGV = 128 + SigNum.SIGSEGV
99 EX_SIGUSR2 = 128 + SigNum.SIGUSR2
100 EX_SIGPIPE = 128 + SigNum.SIGPIPE
101 EX_SIGALRM = 128 + SigNum.SIGALRM
102 EX_SIGTERM = 128 + SigNum.SIGTERM
103 EX_SIGSTKFLT = 128 + SigNum.SIGSTKFLT
104 EX_SIGCHLD = 128 + SigNum.SIGCHLD
105 EX_SIGCONT = 128 + SigNum.SIGCONT
106 EX_SIGSTOP = 128 + SigNum.SIGSTOP
107 EX_SIGTSTP = 128 + SigNum.SIGTSTP
108 EX_SIGTTIN = 128 + SigNum.SIGTTIN
109 EX_SIGTTOU = 128 + SigNum.SIGTTOU
110 EX_SIGURG = 128 + SigNum.SIGURG
111 EX_SIGXCPU = 128 + SigNum.SIGXCPU
112 EX_SIGXFSZ = 128 + SigNum.SIGXFSZ
113 EX_SIGVTALRM = 128 + SigNum.SIGVTALRM
114 EX_SIGPROF = 128 + SigNum.SIGPROF
115 EX_SIGWINCH = 128 + SigNum.SIGWINCH
116 EX_SIGPOLL = 128 + SigNum.SIGPOLL
117 EX_SIGPWR = 128 + SigNum.SIGPWR
118 EX_SIGSYS = 128 + SigNum.SIGSYS
119
120 def __str__(self):
121 return "{name}<{value:d}(0x{value:02X})>".format(
122 name=self.name,
123 value=self.value
124 )