From 89e914e9d182a4464b8cd7166517b397cad66737 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Mon, 2 Jan 2012 18:46:30 -0500 Subject: [PATCH] ui-macos/main.py: fix wait() to avoid deadlock. If the subprocess was trying to write to its stdout/stderr, its process would never actually finish because it was blocked waiting for us to read it, but we were blocked on waitpid(). Instead, use waitpid(WNOHANG) and continually read from the subprocess (which should be a blocking operation) until it exits. --- ui-macos/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui-macos/main.py b/ui-macos/main.py index 3e6c2a1..7915e91 100644 --- a/ui-macos/main.py +++ b/ui-macos/main.py @@ -87,7 +87,10 @@ class Runner: return self.rv def wait(self): - return self._try_wait(0) + rv = None + while rv is None: + self.gotdata(None) + rv = self._try_wait(os.WNOHANG) def poll(self): return self._try_wait(os.WNOHANG)