summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2012-01-02 18:46:30 -0500
committerBrian May <brian@microcomaustralia.com.au>2014-09-23 10:11:13 +1000
commit5a39341d504091c5183910786ac11523c93b577d (patch)
tree385282c1f86d7e1f5387709d621af3b9c7e16e25
parent3eef3635ac2172940e0eb83e1090221fb35f8581 (diff)
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.
-rw-r--r--src/ui-macos/main.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ui-macos/main.py b/src/ui-macos/main.py
index daecba3..b75678f 100644
--- a/src/ui-macos/main.py
+++ b/src/ui-macos/main.py
@@ -97,7 +97,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)