aha! file descriptor leak in 'readFile'
Simon Marlow
simonmar at microsoft.com
Tue Apr 20 11:19:22 EDT 2004
On 19 April 2004 08:32, John Meacham wrote:
> I have finally tracked down a test case which results in the file
> descriptor leak which has plauged one of my programs since its birth.
>
> this code:
> sequence (replicate 100 $ handle (\_ -> return "") ( readFile "."))
>
> will leak 100 file descriptors, apparently, after a
> Fail: .: openFile: inappropriate type (is a directory)
> exception from readFile, the file descriptor will not be closed, and
> instead be left open til the end o' time.
>
> it took me a long time to find because I thought the bug was in
> the listing of my directories, not the readFile's of its contents
> (including "." and "..").
Yes, that's a bug. Now fixed.
Cheers,
Simon
More information about the Libraries
mailing list