From: Luke Kenneth Casson Leighton Date: Fri, 24 Sep 2021 16:55:09 +0000 (+0100) Subject: use with subprocess to get it to close Popen files X-Git-Tag: sv_maxu_works-initial~834 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cdba960d1dd6a02ee01e3b7a9865fec255aed0cd;p=openpower-isa.git use with subprocess to get it to close Popen files --- diff --git a/src/openpower/simulator/program.py b/src/openpower/simulator/program.py index c2b4adbe..a3dd3754 100644 --- a/src/openpower/simulator/program.py +++ b/src/openpower/simulator/program.py @@ -88,12 +88,12 @@ class Program: self.obj_fmt, "-o", outfile.name] - p = subprocess.Popen(args, stdin=subprocess.PIPE) - p.communicate(self.assembly.encode('utf-8')) - if p.wait() != 0: - print("Error in program:") - print(self.assembly) - sys.exit(1) + with subprocess.Popen(args, stdin=subprocess.PIPE) as p: + p.communicate(self.assembly.encode('utf-8')) + if p.wait() != 0: + print("Error in program:") + print(self.assembly) + sys.exit(1) self._link(outfile) def _get_instructions(self):