diff options
author | 2010-02-28 17:50:38 +0800 | |
---|---|---|
committer | 2010-03-12 13:01:15 +0800 | |
commit | d5d168574bdf350e5d8b40becb572a247a9d5e1e (patch) | |
tree | e7277305eab64e44955eac6b2dc0a4a8d0f762a3 | |
parent | dd459eeaaa5da12ecc5d369b9df46092dc7cc97d (diff) |
process.wait() will hang if the instance sigterms, use poll() + timeout.
-rwxr-xr-x | examples/data/scripts/uzbl-tabbed | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/examples/data/scripts/uzbl-tabbed b/examples/data/scripts/uzbl-tabbed index e542dbf..f07bae4 100755 --- a/examples/data/scripts/uzbl-tabbed +++ b/examples/data/scripts/uzbl-tabbed @@ -528,7 +528,18 @@ class UzblInstance: if self._client: self._client.close() self._client = None - self.process.wait() + + pid = self.process.pid + timeout = time.time() + 5 + + while self.process.poll() is None and time.time() < timeout: + # Sleep between polls. + time.sleep(0.1) + + if self.process.poll() is None: + # uzbl instance didn't exit in time. + error("quit timeout expired, sending SIGTERM to uzbl instance") + self.process.terminate() class UzblTabbed: |