mc = subprocess.Popen([mc, '--version'],
stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
-mc.wait()
-mc_version = mc.stdout.readline()
-mc.stdout.read()
-mc.stdout.close()
+ stderr=subprocess.PIPE,
+ close_fds=True, env={})
+stdout, stderr = mc.communicate()
+if mc.returncode or stderr:
+ sys.exit('Error reading mc version: (%d) %s' % (mc.returncode, stderr))
+mc_version = stdout.split('\n')[0]
if mc_version.startswith('Midnight Commander'):
mc_version = mc_version.split()[2]
elif mc_version.startswith('GNU Midnight Commander') or \