Commits

John Mulligan  committed da81454

fslib: make fdlistdir/fditerdir dup the fd it is given

  • Participants
  • Parent commits 87e7f6c

Comments (0)

Files changed (1)

File fsnix/fswlib.py

 
 def fdlistdir(fd):
     entries = []
-    dirh = _fdopendir(fd)
+    dirh = _fdopendir(os.dup(fd))
     try:
         _libc.rewinddir(dirh)
         _filldirs(dirh, entries, 0)
     def __init__(self, fd, groupsize):
         self.fd = fd
         self.groupsize = groupsize
-        self._dirh = _fdopendir(fd)
+        self._dirh = _fdopendir(os.dup(fd))
         self._buf = []
         _libc.rewinddir(self._dirh)