close(), exceptions and problems
Erwin S. Andreasen
erwin at andreasen.com
Sat Mar 24 07:23:03 EST 2001
On 23 Mar 2001 09:30:46 GMT, Antti Kuntsi wrote:
>I have run into the following problem with python and close()s. When the
>system is under a heavy load the close() system call can be interrupted,
>but the Python never detects this. This leads into a lot of problems,
>including at least the following:
What exactly do you mean by "interrupted" ?
close(), the system call, usually cannot fail (unless you try to close a fd
that is not open).
If a system call is interrupted by a signal, it is restarted automatically
(unless the signal handler was setup with SA_NORESTART *or* the system call in
question is select(), which is never automatically restarted).
But if you call close(fd) you aren't supposed to do something like:
int fd, rv;
while (((rv = close(fd)) < 0 && errno == EINTR))
;
if (rv < 0)
perror("close");
the system call will be automatically restarted for you.
--
=======================================================================
<erwin at andreasen.com> Herlev, Denmark Software Designer
<URL:http://www.andreasen.org/> <*> LASAT^WEicon Networks
=======================================================================
More information about the Python-list
mailing list