PATCH: Get rid of superfluous dup() and close() calls.

David Laight david at l8s.co.uk
Sat Feb 1 03:53:52 CST 2003


> I'm not sure I agree. When someone closes a fd they shouldn't, that 
> would lead to program crashing, and attention being brought to the 
> problem. When someone leaks a fd, noone will notice.

No, it causes horrid corruptions that are particularly difficult
to find.

What happens is that someone else does an open() and is given
the number of the (incorrectly) closed fd.  The owener of the fd
will then write into the newly opened file.

This can happen if a 'normal' program does close(0), close(1),
close(2) then much later accidentally calls printf() instead
of sprintf().  When the stdio buffer is eventually flushed data
is written to what has been reopened as fd0.
(This was a real bug in software that got released...)

	David

-- 
David Laight: david at l8s.co.uk



More information about the wine-devel mailing list