comparison mxtool/mx.py @ 15701:16059f6f5661

mx: drain *all* output from subprocess if redirecting to functions
author Doug Simon <doug.simon@oracle.com>
date Fri, 16 May 2014 12:06:46 +0200
parents e563b7668db5
children 8b9e7f235d85
comparison
equal deleted inserted replaced
15700:98423229008c 15701:16059f6f5661
1503 stderr = err if not callable(err) else subprocess.PIPE 1503 stderr = err if not callable(err) else subprocess.PIPE
1504 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env) 1504 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env)
1505 sub = _addSubprocess(p, args) 1505 sub = _addSubprocess(p, args)
1506 if callable(out): 1506 if callable(out):
1507 t = Thread(target=redirect, args=(p.stdout, out)) 1507 t = Thread(target=redirect, args=(p.stdout, out))
1508 t.daemon = True # thread dies with the program 1508 # Don't make the reader thread a daemon otherwise output can be droppped
1509 t.start() 1509 t.start()
1510 if callable(err): 1510 if callable(err):
1511 t = Thread(target=redirect, args=(p.stderr, err)) 1511 t = Thread(target=redirect, args=(p.stderr, err))
1512 t.daemon = True # thread dies with the program 1512 # Don't make the reader thread a daemon otherwise output can be droppped
1513 t.start() 1513 t.start()
1514 if timeout is None or timeout == 0: 1514 if timeout is None or timeout == 0:
1515 retcode = waitOn(p) 1515 retcode = waitOn(p)
1516 else: 1516 else:
1517 if get_os() == 'windows': 1517 if get_os() == 'windows':