diff options
author | Maciej Zygmanowski <sppmacd@pm.me> | 2021-06-04 17:10:24 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-04 19:11:27 +0200 |
commit | bee1e06055234fa413034e632ec1d6a9f7d4451f (patch) | |
tree | 7cdc25a7213cbce246a42faf6ad41f6e0d6e0687 | |
parent | d840608a5177addef2b1144c0d5706a063b54ad5 (diff) | |
download | serenity-bee1e06055234fa413034e632ec1d6a9f7d4451f.zip |
hostname: Handle 'sethostname' errors
-rw-r--r-- | Userland/Utilities/hostname.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Utilities/hostname.cpp b/Userland/Utilities/hostname.cpp index 4694480903..b620242f50 100644 --- a/Userland/Utilities/hostname.cpp +++ b/Userland/Utilities/hostname.cpp @@ -31,7 +31,11 @@ int main(int argc, char** argv) warnln("Hostname must be less than {} characters", HOST_NAME_MAX); return 1; } - sethostname(hostname, strlen(hostname)); + int rc = sethostname(hostname, strlen(hostname)); + if (rc < 0) { + perror("sethostname"); + return 1; + } } return 0; } |