[glibc] Return different exit codes when gai_result is > -100

Adhemerval Zanella via Glibc-cvs <[email protected]>
Newsgroups gmane.comp.lib.glibc.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=842ad56879c8abe4ff8bc6ccc5097d2755e52527

commit 842ad56879c8abe4ff8bc6ccc5097d2755e52527
Author: Petr Menšík <[email protected]>
Date:   Thu Oct 16 16:18:23 2025 +0200

    Return different exit codes when gai_result is > -100
    
    Make the result checkable from the command line even without verbose
    mode. Keep original exit status 2 for name not found error. But report
    other errors by exit status greater than 10.
    
    For too high values make it return 2 as before.
    
    Signed-off-by: Petr Menšík <[email protected]>
    Reviewed-by: Adhemerval Zanella  <[email protected]>

Diff:
---
 nss/getent.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/nss/getent.c b/nss/getent.c
index 7e78edabdf..d591b7ac0b 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -368,10 +368,13 @@ ahosts_keys_int (int af, int xflags, int number, char *key[])
 
       if (gai_result != 0)
 	{
-	  result = 2;
 	  if (gai_verbose)
 	    fprintf (stderr, _("Host %s failed: %s\n"), key[i],
 			    gai_strerror (gai_result));
+	  if (gai_result >= EAI_INPROGRESS && gai_result != EAI_NONAME)
+	    result = 10 + abs (gai_result);
+	  else
+	    result = 2;
 	}
       else
 	{
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.