30 lines
836 B
Diff
30 lines
836 B
Diff
Index: tcsh/sh.misc.c
|
|
===================================================================
|
|
--- tcsh.orig/sh.misc.c 2005-01-05 17:06:14.000000000 +0100
|
|
+++ tcsh/sh.misc.c 2005-01-09 16:47:41.068433880 +0100
|
|
@@ -251,6 +251,7 @@
|
|
closem()
|
|
{
|
|
int f;
|
|
+ struct stat st;
|
|
|
|
#ifdef NLS_BUGS
|
|
#ifdef NLS_CATALOGS
|
|
@@ -267,6 +268,16 @@
|
|
#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
|
|
)
|
|
{
|
|
(void) close(f);
|