[kupfer] utils: Add exit_status attribute to AsyncCommand



commit 6e002858686c3e4c9a151805fdb6e30e69a10223
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Tue Mar 1 21:08:56 2011 +0100

    utils: Add exit_status attribute to AsyncCommand

 kupfer/utils.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/utils.py b/kupfer/utils.py
index b813588..c9d7d7a 100644
--- a/kupfer/utils.py
+++ b/kupfer/utils.py
@@ -89,6 +89,11 @@ class AsyncCommand (object):
 	If stdin is a byte string, it is supplied on the command's stdin.
 
 	finish_callback -> (AsyncCommand, stdout_output, stderr_output)
+
+	Attributes:
+	self.exit_status  Set after process exited
+	self.finished     bool
+
 	"""
 	# the maximum input (bytes) we'll read in one shot (one io_callback)
 	max_input_buf = 512 * 1024
@@ -154,6 +159,8 @@ class AsyncCommand (object):
 		return False
 
 	def _child_callback(self, pid, condition):
+		# @condition is the &status field of waitpid(2) (C library)
+		self.exit_status = os.WEXITSTATUS(condition)
 		self.finished = True
 		self.finish_callback(self, "".join(self.stdout), "".join(self.stderr))
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]