close(), exceptions and problems

Antti Kuntsi kuntsi at cc.helsinki.fi.spam.no
Mon Mar 26 16:56:43 EST 2001


Jeff Epler <jepler at inetnebr.com> wrote:
> Well, *either*
> 	1) The system returns -EINTR on close() and the file is not closed.
> 	   This should cause fclose() to return EOF, and Python to raise
> 	   an IOError.
> 	2) The system restarts the close() syscall internally in fclose().
> 	   When the fclose() call returns, it must have succeeded.
> I don't see how anything else could happen.
> 
> However, I did just notice one potential problem when the system raises
> IOError on close.  Regardless of the returned value from f->f_close(f->f_fp),
> f->f_fp is set to NULL.  Thus, if close() returns -EINTR, the underlying fd
> is not closed, but the file is marked as closed, and in effect the file is
> "leaked".
> 
> Could this be the behavior the original poster was referring to?

Close, the problem is that the implementation in at least Python 1.5.2
does not check the return code of the close() and thus does not raise an
exception, at least not with sockets.

Antti

-- 
         /"\                           |    iki.
         \ /     ASCII Ribbon Campaign |    fi/
          X      Against HTML Mail     |    mickut
         / \



More information about the Python-list mailing list