From c9b396340b3acad149d4cb56791083dc7d78480f Mon Sep 17 00:00:00 2001 From: Morten Enemark Lund Date: Tue, 5 Nov 2019 17:23:12 +0100 Subject: [PATCH 1/2] Fix issue with taskkill after ctrl-c on win This fixes an issue on Win where pressing ctrl-c after could sometimes result in a traceback if the process had already quit. It also stops taskkill from printing to standard error. --- xonsh/jobs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xonsh/jobs.py b/xonsh/jobs.py index 20d5923b57..67a5ecca54 100644 --- a/xonsh/jobs.py +++ b/xonsh/jobs.py @@ -71,7 +71,10 @@ def _continue(job): job["status"] = "running" def _kill(job): - subprocess.check_output(["taskkill", "/F", "/T", "/PID", str(job["obj"].pid)]) + subprocess.check_output( + ["taskkill", "/F", "/T", "/PID", str(job["obj"].pid)], + stderr=subprocess.STDOUT, + ) def ignore_sigtstp(): pass @@ -96,7 +99,10 @@ def wait_for_active_job(last_task=None, backgrounded=False): except subprocess.TimeoutExpired: pass except KeyboardInterrupt: - _kill(active_task) + try: + _kill(active_task) + except subprocess.CalledProcessError: + pass # ignore error if process closed before we got here return wait_for_active_job(last_task=active_task) From 20b226e44c1cfba0e1334a94e1ef7805acc4b42b Mon Sep 17 00:00:00 2001 From: Morten Enemark Lund Date: Tue, 5 Nov 2019 17:27:24 +0100 Subject: [PATCH 2/2] Add news file --- news/kill-win.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 news/kill-win.rst diff --git a/news/kill-win.rst b/news/kill-win.rst new file mode 100644 index 0000000000..d6abdf9412 --- /dev/null +++ b/news/kill-win.rst @@ -0,0 +1,24 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Fixed an issue on Windows where pressing ctrl-c could sometimes result + in a traceback if the process had already quit before being killed by xonsh. + +**Security:** + +*