document: fix content indexer's handling of the "file" command

Content indexer spawns the *nix "file" command in an attempt to determine
the type of arbitrary files. The way we have fetched the stdout of the
child process had been flawed, leaving a zombie process for every file
scanned. It was not a matter of closing the file descriptors, rather an
issue of cleaning up the child process.

bzr revid: p_christ@hol.gr-20101209112607-psu98d0h2e7xqwu7
This commit is contained in:
P. Christeas
2010-12-09 13:26:07 +02:00
parent 9023049b49
commit 18a5ade8fd
+3 -5
View File
@@ -165,11 +165,9 @@ class contentIndex(object):
os.write(fd, content)
os.close(fd)
fp = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE).stdout
try:
result = fp.read()
finally:
fp.close()
pop = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE)
(result, _) = pop.communicate()
mime2 = result.split(';')[0]
self.__logger.debug('File gave us: %s', mime2)
# Note that the temporary file still exists now.