diff options
author | Karel Zak | 2018-02-01 14:58:52 +0100 |
---|---|---|
committer | Karel Zak | 2018-02-01 14:58:52 +0100 |
commit | cf654e1c3ec8f6f9ac93bf4f6981d560249868d9 (patch) | |
tree | 6741056f336fae92b89c357b0779814c9711cb9d /include | |
parent | findfs: don't include exitcodes.h (diff) | |
download | kernel-qcow2-util-linux-cf654e1c3ec8f6f9ac93bf4f6981d560249868d9.tar.gz kernel-qcow2-util-linux-cf654e1c3ec8f6f9ac93bf4f6981d560249868d9.tar.xz kernel-qcow2-util-linux-cf654e1c3ec8f6f9ac93bf4f6981d560249868d9.zip |
include/c: add errexec()
The new errexec() macro consolidate and unify the way how util-linux
tools react to failed exec()-like functions:
* exit code 126 when program located, but not usable
* exit code 127 when could not find program to exec
The exit codes are compatible with coreutils.
Note that all the change is located in c.h; the file exitcodes.h
contains API specific (mkfs, fsck, ...) codes only.
Addresses: https://github.com/karelzak/util-linux/pull/311
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/c.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/c.h b/include/c.h index b0670dcaa..c8bcb375b 100644 --- a/include/c.h +++ b/include/c.h @@ -216,6 +216,12 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...) exit(eval); \ }) +/* After failed execvp() */ +#define EX_EXEC_FAILED 126 /* Program located, but not usable. */ +#define EX_EXEC_ENOENT 127 /* Could not find program to exec. */ +#define errexec(name) err(errno == ENOENT ? EX_EXEC_ENOENT : EX_EXEC_FAILED, \ + _("failed to execute %s"), name) + static inline __attribute__((const)) int is_power_of_2(unsigned long num) { |