diff testcases.py @ 65:fcb5ab97f08e

Improved run-time reporting and fixed a potential hang on POSIX
author Oleg Oshmyan <chortos@inbox.lv>
date Wed, 22 Dec 2010 22:28:10 +0200
parents fb9d0223a871
children c0f1b87013ad
line wrap: on
line diff
--- a/testcases.py	Wed Dec 22 19:12:45 2010 +0200
+++ b/testcases.py	Wed Dec 22 22:28:10 2010 +0200
@@ -92,7 +92,11 @@
 	from signal import SIGCHLD, signal, SIG_DFL
 	from select import select, error as select_error
 	from errno import EINTR
-	import pickle
+	import fcntl
+	try:
+		import cPickle as pickle
+	except ImportError:
+		import pickle
 except ImportError:
 	try:
 		from _subprocess import WAIT_OBJECT_0, STD_INPUT_HANDLE, INFINITE
@@ -191,7 +195,9 @@
 			os.close(read)
 			if preexec_fn_:
 				preexec_fn_()
-			os.write(write, pickle.dumps(clock(), 1))
+			fcntl.fcntl(write, fcntl.F_SETFD, fcntl.fcntl(write, fcntl.F_GETFD) | getattr(fcntl, 'FD_CLOEXEC', 1))
+			fwrite = os.fdopen(write, 'ab')
+			pickle.dump(clock(), fwrite, 1)
 		kwargs['preexec_fn'] = preexec_fn
 		try:
 			case.process = Popen(*args, **kwargs)