def close_fds(self, exclude):
if type(exclude) != list:
raise Exception('exclude is not a list: %s' % exclude)
for i in exclude:
if type(i) != int:
raise Exception('exclude is not a list of int: %s' % exclude)
# close all file descriptors except 0,1,2, whatever file descriptor is
# connected to /dev/ptmx, and whatever the subclass wants to keep open.
exclude.extend([0,1,2])
for fd in self.list_fds().keys():
if fd in exclude:
continue
try:
os.close(fd)
except OSError, e:
if e.errno == errno.EBADF:
continue
raise
评论列表
文章目录