Handle invalid file descriptor in exit

This commit is contained in:
Kenneth Lyons 2019-06-23 12:14:52 -07:00
parent 9653254094
commit 563083cf86

View File

@ -369,8 +369,12 @@ def exit():
## close file handles
if sys.platform == 'darwin':
for fd in range(3, 4096):
if fd not in [7]: # trying to close 7 produces an illegal instruction on the Mac.
if fd in [7]: # trying to close 7 produces an illegal instruction on the Mac.
continue
try:
os.close(fd)
except OSError:
pass
else:
os.closerange(3, 4096) ## just guessing on the maximum descriptor count..