fixed wrong error checking on fcntl call as per SF bug # 821896

(same as commit of Sun Nov 2 to the release23-maint branch)
This commit is contained in:
Alex Martelli 2003-11-09 16:44:09 +00:00
parent 0c5b4ad8f2
commit f09994e527
1 changed files with 3 additions and 2 deletions

View File

@ -47,8 +47,9 @@ except (ImportError, AttributeError):
pass
else:
def _set_cloexec(fd):
flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
if flags >= 0:
try: flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
except IOError: pass
else:
# flags read successfully, modify
flags |= _fcntl.FD_CLOEXEC
_fcntl.fcntl(fd, _fcntl.F_SETFD, flags)