Skip to content

Instantly share code, notes, and snippets.

@detly
Created March 15, 2015 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save detly/22284275762bbf9c86d6 to your computer and use it in GitHub Desktop.
Save detly/22284275762bbf9c86d6 to your computer and use it in GitHub Desktop.
top failure
#!/usr/bin/env python2
import subprocess
import time
# Start 'top'
the_proc = subprocess.Popen(['top'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Just kill it after a couple of seconds
time.sleep(2)
the_proc.terminate()
stdout, stderr = the_proc.communicate()
print(stdout)
print(stderr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment