tcsh/tcsh-6.15.00-closem.patch
2007-08-27 15:05:02 +00:00

28 lines
818 B
Diff

--- tcsh-6.15.00/sh.misc.c_old 2006-10-14 19:57:21.000000000 +0200
+++ tcsh-6.15.00/sh.misc.c 2007-08-27 15:55:20.000000000 +0200
@@ -255,6 +255,7 @@
closem(void)
{
int f, num_files;
+ struct stat st;
#ifdef NLS_BUGS
#ifdef NLS_CATALOGS
@@ -272,6 +273,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
)
{
xclose(f);