Bug#290507: vim does not close file upon :sh

Bram Moolenaar Bram at Moolenaar.net
Fri Sep 11 11:36:45 UTC 2009


James -

> > > > On Sat, Oct 07, 2006 at 03:32:45PM +0200, Bram Moolenaar wrote:
> > > > 
> > > > ugh, cough, that's a dusty email!
> > > 
> > > I finally had a chance to look into this and find how we could avoid it.
> > > :)
> > > 
> > > > On Sat, Oct 07, 2006 at 03:32:45PM +0200, Bram Moolenaar wrote:
> > > > > > Hmm, perhaps the problem is that system() or execvp() doesn't close the
> > > > > > file descriptors in a child process?
> > > > > 
> > > > > Indeed, that is the case.  Children inherit their parent's file
> > > > > descriptors unless the file descriptors are set to close on exec().
> > > > > Attached patch does that.
> > > > 
> > > > I don't think the FD_CLOEXEC flag is always available.  I'm not sure
> > > > when it was added.  Adding an autoconf check for it will help to avoid
> > > > breaking the build on old systems.
> > > 
> > > I don't know autoconf, so I'm afraid I wouldn't be able to provide this
> > > part of the patch any time soon.  FD_CLOEXEC is required by POSIX
> > > though, so I'm unsure how much this check is really needed.
> > > 
> > > > This page mentions that one should get the flags first:
> > > > http://www.cs.ui.ac.id/WebKuliah/IKI10100/resources/contest/OnlineJudge/gnudoc/libc/Descriptor_Flags.html
> > > 
> > > Ah, yes.  Currently FD_CLOEXEC is the only supported flag, but that
> > > would be the proper way to do this for long-term robustness.  Should I
> > > update this part of the patch or will you take care of it with the
> > > autoconf checks?
> > 
> > I would appreciate it if you can update the patch as far as you can and
> > test it.  Then I'll have a look at it as well.  It's always better to
> > have more than one person look at these things to avoid mistakes.
> 
> Updated patch attached.  The flags are retrieved first and F_SETFD is
> only called if that was successful and FD_CLOEXEC isn't already set.
> I've also added an autoconf check which defines HAVE_FD_CLOEXEC if it is
> successful.  That is also used to guard the related code instead of the
> previous "#ifdef UNIX".
> 
> I followed the model of similar autoconf checks for the FD_CLOEXEC
> check.  I think it should be sufficient but I don't have any systems
> which have fcntl.h yet don't define FD_CLOEXEC.

Now that I wanted to look into this I notice that you forgot to attach
the patch.

- Bram

-- 
hundred-and-one symptoms of being an internet addict:
224. You set up your own Web page. You set up a Web page for each
     of your kids... and your pets.

 /// Bram Moolenaar -- Bram at Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///





More information about the pkg-vim-maintainers mailing list