comparison unix.py @ 134:e84f33a60a5c

Moved process killing logic into platform-specific modules
author Oleg Oshmyan <chortos@inbox.lv>
date Fri, 20 May 2011 14:47:42 +0100
parents 580f0f4687c3
children ed4035661b85
comparison
equal deleted inserted replaced
133:a9d2aa6810c7 134:e84f33a60a5c
20 from signal import SIGTERM, SIGKILL 20 from signal import SIGTERM, SIGKILL
21 except ImportError: 21 except ImportError:
22 SIGTERM = 15 22 SIGTERM = 15
23 SIGKILL = 9 23 SIGKILL = 9
24 24
25 __all__ = 'call', 'kill', 'terminate', 'wait', 'pause', 'clock' 25 __all__ = 'call', 'kill', 'pause', 'clock'
26 26
27 27
28 if not sys.stdin.isatty(): 28 if not sys.stdin.isatty():
29 pause = lambda: sys.stdin.read(1) 29 pause = lambda: sys.stdin.read(1)
30 catch_escape = False 30 catch_escape = False
289 def kill(process): 289 def kill(process):
290 try: 290 try:
291 process.kill() 291 process.kill()
292 except AttributeError: 292 except AttributeError:
293 os.kill(process.pid, SIGKILL) 293 os.kill(process.pid, SIGKILL)
294 294 wait(process)
295
296 def terminate(process):
297 try:
298 process.terminate()
299 except AttributeError:
300 os.kill(process.pid, SIGTERM)
301 295
302 296
303 # subprocess in Python 2.6- is not guarded against EINTR 297 # subprocess in Python 2.6- is not guarded against EINTR
304 try: 298 try:
305 from errno import EINTR 299 from errno import EINTR