Index: test/tools/lldb-server/gdbremote_testcase.py =================================================================== --- test/tools/lldb-server/gdbremote_testcase.py +++ test/tools/lldb-server/gdbremote_testcase.py @@ -333,7 +333,14 @@ if sleep_seconds: args.append("sleep:%d" % sleep_seconds) - return self.spawnSubprocess(exe_path, args) + inferior = self.spawnSubprocess(exe_path, args) + def shutdown_process_for_attach(): + try: + inferior.terminate() + except: + logger.warning("failed to close pexpect inferior for process for attach: {}; ignoring".format(sys.exc_info()[0])) + self.addTearDownHook(shutdown_process_for_attach) + return inferior def prep_debug_monitor_and_inferior(self, inferior_args=None, inferior_sleep_seconds=3, inferior_exe_path=None): """Prep the debug monitor, the inferior, and the expected packet stream.