This repository was archived by the owner on Jun 30, 2025. It is now read-only.
On Solaris, GetHostName() returns empty string#783
Merged
sergiud merged 1 commit intogoogle:masterfrom Jan 19, 2022
Merged
Conversation
As per https://docs.oracle.com/cd/E18752_01/html/816-5167/uname-2.html#REFMAN2uname-2 Solaris version of uname() return a non-negative value on success. Modifying this code to check for a return value of less than zero will work on Solaris as well as Linux and AIX.
Codecov Report
@@ Coverage Diff @@
## master #783 +/- ##
=======================================
Coverage 72.65% 72.65%
=======================================
Files 17 17
Lines 3247 3247
=======================================
Hits 2359 2359
Misses 888 888
Continue to review full report at Codecov.
|
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently on SunOS, a call to
GetHostName()will return an empty hostname. This is because the return value ofuname()is a "non-negative value" as per the man page, but in my testing it seems to return 1. This causes the returned hostname value to be an empty string in calls toGetHostName()or "(unknown)" in calls toLogDestination::hostname(). Example log file:Changes
Modifying this code to check for a return value of less than zero will work on Solaris as well as Linux and AIX. I don't know how useful this would be to the general populace seeing most folks are running on Linux, but I figured it wouldn't hurt considering the triviality of the actual code change.
Notes
Solaris uname manpage
AIX uname manpage
Linux manpage