[qmtest] [PATCH] Reliably close stdin in 'qm.executable.Filter'

Nathaniel Smith njs at pobox.com
Fri Aug 15 04:54:43 UTC 2003


On Thu, Aug 14, 2003 at 05:24:16PM -0700, Mark Mitchell wrote:
> On Thu, 2003-08-14 at 16:38, Nathaniel Smith wrote:
> > This patch modifies 'TimeoutExecutable' so that the monitor process it
> > creates closes all fds; this fixes a bug where children spawned by
> > 'Filter' would not see their stdin closed at the appropriate time.
> > Also adds a new test for this.
> 
> Cool.
> 
> +                # Close all fds.  This is especially important to avoid
> +                # keeping any pipes to the child process open after our
> +                # parent has closed them.
> 
> Let's be a little more specific.  How about:
> 
> Close all open file descriptors.  They are not needed in the monitor
> process.  Furthermore, when the parent closes the write end of the stdin
> pipe to the child, we do not want the pipe to remain open; leaving the
> pipe open might cause the child to block waiting for additional input.
> 
> ?

Sure, that is more informative.

> +                for fd in range(max_fds):
> 
> Should that use xrange?  I'm never quite sure when one is a win over the
> other.  I'll trust your judgement.

Eh, I'm never really sure either.  I think I'll switch to xrange on
the principle that it generally makes more sense to worry about
scaling to large numbers than to small ones, and I've never really
understood how xrange could be slower than range anyway.

Committed with these changes.

-- Nathaniel

-- 
Details are all that matters; God dwells there, and you never get to
see Him if you don't struggle to get them right. -- Stephen Jay Gould



More information about the qmtest mailing list