From 3d82ff41ecb8173886dfbf3d2960cfcf929be24c Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sun, 28 Aug 2011 22:29:38 +0000 Subject: [PATCH] Close stdin of the command spawn by subprocess.Popen, otherwise the command hangs if something goes wrong. Also allow any kind of line endings. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39553 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/configure.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/configure.py b/lib/configure.py index e2cfab7f98..add430ccfc 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -60,9 +60,11 @@ def cmdOutput(cmd): '''utility function: run a command and get its output as a string cmd: command to run ''' - fout = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout - output = fout.read() - fout.close() + pipe = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, \ + stdout=subprocess.PIPE, universal_newlines=True) + pipe.stdin.close() + output = pipe.stdout.read() + pipe.stdout.close() return output.strip() @@ -1104,15 +1106,18 @@ def checkLatexConfig(check_config, bool_docbook): cl.close() # # we have chklayouts.tex, then process it - fout = subprocess.Popen([LATEX, "wrap_chkconfig.ltx"], stdout=subprocess.PIPE).stdout + pipe = subprocess.Popen([LATEX, "wrap_chkconfig.ltx"], \ + stdin=subprocess.PIPE, stdout=subprocess.PIPE, \ + universal_newlines=True) + pipe.stdin.close() while True: - line = fout.readline() + line = pipe.stdout.readline() if not line: break; if re.match('^\+', line): logger.info(line.strip()) # if the command succeeds, None will be returned - ret = fout.close() + ret = pipe.stdout.close() # # currently, values in chhkconfig are only used to set # \font_encoding -- 2.39.2