Guest User

Untitled

a guest
Jun 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import subprocess
  2. import time
  3.  
  4. exec_proc = subprocess.Popen("/usr/bin/time -f \"%e\\n%M\" ./son > /dev/null", stdout = subprocess.PIPE, stderr = subprocess.STDOUT, shell = True)
  5.  
  6. max_time = 1
  7. cur_time = 0.0
  8. return_code = 0
  9. while cur_time <= max_time:
  10. if exec_proc.poll() != None:
  11. return_code = exec_proc.poll()
  12. break
  13. time.sleep(0.1)
  14. cur_time += 0.1
  15.  
  16. if cur_time > max_time:
  17. exec_proc.kill()
Add Comment
Please, Sign In to add comment