Skip to content

Instantly share code, notes, and snippets.

@rafaelcanovas
Created February 24, 2014 18:43
Show Gist options
  • Save rafaelcanovas/9194296 to your computer and use it in GitHub Desktop.
Save rafaelcanovas/9194296 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from subprocess import call, check_output, CalledProcessError
top_ps = check_output('ps haxo pid,command k -pcpu | head -n 1', shell=True)
top_ps = str(top_ps, encoding='UTF-8')
top_pid, top_cmd = top_ps.strip().split(' ', 1)
try:
question = check_output([
'zenity',
'--question',
'--title', 'Killtop',
'--text', 'Tem certeza que deseja matar o processo `%s`?' % top_cmd
])
call(['kill', top_pid])
except CalledProcessError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment