Incorrect handling of EINTR in Bazaar

Martin Pool mbp at canonical.com
Fri Feb 19 01:50:59 GMT 2010


On 19 February 2010 12:08, Andrew Bennetts
<andrew.bennetts at canonical.com> wrote:

>>   file.close
>>     Bogus as first invalidates the internal handle so no point
>> re-calling, see close_the_file in Objects/fileobject.c
>
> My man page for close(2) lists the errors it can return, and includes:
>
>       EINTR  The close() call was interrupted by a signal; see signal(7).
>
> Perhaps not actually possible in practice for regular files or pipes?  It
> does look like a bug in Python, it will leak the fd if EINTR occurs.
>
> Anyway, you're right, we can't usefully catch EINTR from Python in this
> case.  Well, actually, we could remember the fileno, and if EINTR occurs
> then until_no_eintr(os.close, fileno), but that's probably not worth the
> effort just to avoid leaking an fd in this corner case.

No, actually I think it is important that you handle this, because
close has larger effects than just closing the filehandle.  If it is
never successfully called then eg the network socket may not close,
and this is just the kind of case where you are likely to see eintr.

-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list