From cc468d499ee83f6b6ed876ef90aaf845eb6c65dd Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Fri, 23 Mar 2018 13:35:08 -0400 Subject: [PATCH] Fixed process hanging issue. --- news/checkend.rst | 14 ++++++++++++++ xonsh/proc.py | 8 +++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 news/checkend.rst diff --git a/news/checkend.rst b/news/checkend.rst new file mode 100644 index 000000000..509194fb3 --- /dev/null +++ b/news/checkend.rst @@ -0,0 +1,14 @@ +**Added:** None + +**Changed:** None + +**Deprecated:** None + +**Removed:** None + +**Fixed:** + +* Fixed hanging issue with pipelines whose middle processes exit before the + first or last process. + +**Security:** None diff --git a/xonsh/proc.py b/xonsh/proc.py index 33933c19a..4a017e31d 100644 --- a/xonsh/proc.py +++ b/xonsh/proc.py @@ -2062,16 +2062,18 @@ class CommandPipeline: """Boolean for if all previous processes have completed. If there is only a single process in the pipeline, this returns False. """ + any_running = False for s, p in zip(self.specs[:-1], self.procs[:-1]): + if p.poll() is None: + any_running = True + continue self._safe_close(p.stdin) self._safe_close(s.stdin) - if p.poll() is None: - return False self._safe_close(p.stdout) self._safe_close(s.stdout) self._safe_close(p.stderr) self._safe_close(s.stderr) - return len(self) > 1 + return False if any_running else (len(self) > 1) def _close_prev_procs(self): """Closes all but the last proc's stdout."""