Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import time
- exec_proc = subprocess.Popen("/usr/bin/time -f \"%e\\n%M\" ./son > /dev/null", stdout = subprocess.PIPE, stderr = subprocess.STDOUT, shell = True)
- max_time = 1
- cur_time = 0.0
- return_code = 0
- while cur_time <= max_time:
- if exec_proc.poll() != None:
- return_code = exec_proc.poll()
- break
- time.sleep(0.1)
- cur_time += 0.1
- if cur_time > max_time:
- exec_proc.kill()
Add Comment
Please, Sign In to add comment