summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2021-11-06 23:25:25 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-08 00:34:58 +0100
commit99b8750154ef490c5c07a412d4666e91f643596e (patch)
tree8e45e8894b31b7e3996f288338e64c725f05b3bb /Userland
parentc706b2c142865df9d2da8d7eda75427b8618b146 (diff)
downloadserenity-99b8750154ef490c5c07a412d4666e91f643596e.zip
syscall: Translate errno to something human-readable
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Utilities/syscall.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Utilities/syscall.cpp b/Userland/Utilities/syscall.cpp
index 6fce710ea6..de119af74a 100644
--- a/Userland/Utilities/syscall.cpp
+++ b/Userland/Utilities/syscall.cpp
@@ -9,6 +9,7 @@
#include <AK/Iterator.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
+#include <errno_numbers.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -93,12 +94,14 @@ int main(int argc, char** argv)
dbgln_if(SYSCALL_1_DEBUG, "Calling {} {:p} {:p} {:p}\n", arg[0], arg[1], arg[2], arg[3]);
int rc = syscall(arg[0], arg[1], arg[2], arg[3]);
- if (rc == -1)
- perror("syscall");
if (output_buffer)
fwrite(outbuf, 1, sizeof(outbuf), stdout);
- warnln("Syscall return: {}", rc);
+ if (-rc >= 0 && -rc < EMAXERRNO) {
+ warnln("Syscall return: {} ({})", rc, strerror(-rc));
+ } else {
+ warnln("Syscall return: {} (?)", rc);
+ }
return 0;
}