29 lines
901 B
Diff
29 lines
901 B
Diff
diff -up tcsh-6.15.00/sh.misc.c.closem tcsh-6.15.00/sh.misc.c
|
|
--- tcsh-6.15.00/sh.misc.c.closem 2006-10-14 19:57:21.000000000 +0200
|
|
+++ tcsh-6.15.00/sh.misc.c 2008-08-29 12:26:41.000000000 +0200
|
|
@@ -255,6 +255,7 @@ void
|
|
closem(void)
|
|
{
|
|
int f, num_files;
|
|
+ struct stat st;
|
|
|
|
#ifdef NLS_BUGS
|
|
#ifdef NLS_CATALOGS
|
|
@@ -272,6 +273,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);
|