From 18a5ade8fd72edcbca951240d4071f2a8fccaa48 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Thu, 9 Dec 2010 13:26:07 +0200 Subject: [PATCH] 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 --- addons/document/content_index.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/document/content_index.py b/addons/document/content_index.py index 6d49a29873f..72cb8f6e163 100644 --- a/addons/document/content_index.py +++ b/addons/document/content_index.py @@ -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.