# HG changeset patch # User Steve Losh # Date 1351722145 14400 # Node ID c6c954131eecac45080a72c1c0acda07f59df31d # Parent 81a3eeb15918b81536792a9ab4333531aeebd10c Don't hang on things like named pipes and sockets. diff -r 81a3eeb15918 -r c6c954131eec ffind --- a/ffind Fri Oct 26 11:38:52 2012 -0400 +++ b/ffind Wed Oct 31 18:22:25 2012 -0400 @@ -444,7 +444,11 @@ 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