diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 40f160623bf..d2de5b30484 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -621,9 +621,14 @@ void os::print_jni_name_suffix_on(outputStream* st, int args_size) { bool os::get_host_name(char* buf, size_t buflen) { struct utsname name; - uname(&name); - jio_snprintf(buf, buflen, "%s", name.nodename); - return true; + int retcode = uname(&name); + if (retcode != -1) { + jio_snprintf(buf, buflen, "%s", name.nodename); + return true; + } + const char* errmsg = os::strerror(errno); + log_warning(os)("Failed to get host name, error message: %s", errmsg); + return false; } #ifndef _LP64