Skip to content

Instantly share code, notes, and snippets.

Created October 26, 2010 13:58
Show Gist options
  • Save anonymous/646935 to your computer and use it in GitHub Desktop.
Save anonymous/646935 to your computer and use it in GitHub Desktop.
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment