develooper Front page | perl.perl5.porters | Postings from December 2004

Re: [Patch] [perl #32446] close leaves fd open

Thread Previous
From:
Steffen Ullrich
Date:
December 2, 2004 00:13
Subject:
Re: [Patch] [perl #32446] close leaves fd open
Message ID:
comiqo$kkb$1@sea.gmane.org
for whatever reason the second message with the patch included did not 
make it on the list. I'll try again. Here is the patch:

--- perlio.c.orig  Mon Aug  9 20:08:55 2004
+++ perlio.c    Wed Dec  1 14:22:48 2004
@@ -2875,6 +2875,13 @@
       */
      f->_file = -1;
      return 1;
+#  elif defined(__OpenBSD__)
+    /* There may be a better way on OpenBSD:
+        - we could insert a dummy func in the _close function entry
+   f->_close = (int (*)(void *)) dummy_close;
+     */
+    f->_file = -1;
+    return 1;
  #  elif defined(__EMX__)
      /* f->_flags &= ~_IOOPEN; */   /* Will leak stream->_buffer */
      f->_handle = -1;



Steffen Ullrich wrote:
> perl #32446 describes a bug with perl5.8 on OpenBSD, where a STDOUT gets 
> duped to a socket and a close(STDOUT) later leaves the socket open. 
> Attached is a proposed and tested fix for the problem, which simply 
> duplicates the FreeBSD code for OpenBSD.
> 
> Details:
> In perlio.c there is a function PerlIOStdio_invalidate_fileno which gets 
> used to close a stdio FILE* without closing the fd. There are a lot of 
> special cases for various platforms and then there is a fallback. 
> Apperantly the fallback is buggy.
> The patch does not attempt to fix the fallback, it simply adds another 
> special case, this time for __OpenBSD__
> 
> 


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About