1. Steve Losh
  2. friendly-find


Steve Losh  committed c6c9541

Don't hang on things like named pipes and sockets.

  • Participants
  • Parent commits 81a3eeb
  • Branches default

Comments (0)

Files changed (1)

File ffind

View file
  • Ignore whitespace
                 return False
         if not options.binary:
-            with open(path) as f:
+            # We open in non-blocking mode so things like file-based sockets
+            # don't hang while waiting for their full kb.
+            # TODO: Ignore those altogether for the binary check?
+            fd = os.open(path, os.O_NONBLOCK)
+            with os.fdopen(fd) as f:
                 if '\0' in f.read(1024):
                     return False