comparison 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
comparison
equal deleted inserted replaced
64:94946bc0a3a8 65:fcb5ab97f08e
90 90
91 try: 91 try:
92 from signal import SIGCHLD, signal, SIG_DFL 92 from signal import SIGCHLD, signal, SIG_DFL
93 from select import select, error as select_error 93 from select import select, error as select_error
94 from errno import EINTR 94 from errno import EINTR
95 import pickle 95 import fcntl
96 try:
97 import cPickle as pickle
98 except ImportError:
99 import pickle
96 except ImportError: 100 except ImportError:
97 try: 101 try:
98 from _subprocess import WAIT_OBJECT_0, STD_INPUT_HANDLE, INFINITE 102 from _subprocess import WAIT_OBJECT_0, STD_INPUT_HANDLE, INFINITE
99 except ImportError: 103 except ImportError:
100 WAIT_OBJECT_0 = 0 104 WAIT_OBJECT_0 = 0
189 read, write = os.pipe() 193 read, write = os.pipe()
190 def preexec_fn(): 194 def preexec_fn():
191 os.close(read) 195 os.close(read)
192 if preexec_fn_: 196 if preexec_fn_:
193 preexec_fn_() 197 preexec_fn_()
194 os.write(write, pickle.dumps(clock(), 1)) 198 fcntl.fcntl(write, fcntl.F_SETFD, fcntl.fcntl(write, fcntl.F_GETFD) | getattr(fcntl, 'FD_CLOEXEC', 1))
199 fwrite = os.fdopen(write, 'ab')
200 pickle.dump(clock(), fwrite, 1)
195 kwargs['preexec_fn'] = preexec_fn 201 kwargs['preexec_fn'] = preexec_fn
196 try: 202 try:
197 case.process = Popen(*args, **kwargs) 203 case.process = Popen(*args, **kwargs)
198 except OSError: 204 except OSError:
199 os.close(read) 205 os.close(read)