Exit with a return code equal to errno in die_perror() to make it easier for the user to get the error code directly. As per man 3 perror, errno is undefined after a successful library call, so save it when entering die_perror(). Signed-off-by: Alexandru Elisei --- util/util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/util.c b/util/util.c index bab4bb394111..fc732200f2dc 100644 --- a/util/util.c +++ b/util/util.c @@ -100,8 +100,10 @@ void __pr_debug(const char *debug, ...) void die_perror(const char *s) { + int e = errno; + perror(s); - exit(1); + exit(e); } void *mmap_hugetlbfs(struct kvm *kvm, const char *htlbfs_path, u64 size) -- 2.53.0