From 01f488c11ec1666c90a81ae2f968f04a9419b186 Mon Sep 17 00:00:00 2001 From: vcrhonek Date: Thu, 24 Jul 2014 15:38:21 +0200 Subject: [PATCH 1/8] do not close sockets orig dist-git commit: f02674e96a7888a7322611b45f6b63a1f5db0fef --- sh.misc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sh.misc.c b/sh.misc.c index 32fc47d..a51dc76 100644 --- a/sh.misc.c +++ b/sh.misc.c @@ -257,6 +257,7 @@ void closem(void) { int f, num_files; + struct stat st; #ifdef NLS_BUGS #ifdef NLS_CATALOGS @@ -274,6 +275,16 @@ closem(void) #ifdef MALLOC_TRACE && f != 25 #endif /* MALLOC_TRACE */ +#ifdef S_ISSOCK + /* NSS modules (e.g. Linux nss_ldap) might keep sockets open. + * If we close such a socket, both the NSS module and tcsh think + * they "own" the descriptor. + * + * Not closing sockets does not make the cleanup use of closem() + * less reliable because tcsh never creates sockets. + */ + && fstat(f, &st) == 0 && !S_ISSOCK(st.st_mode) +#endif ) { xclose(f); -- 1.9.3