kill_process_test.py 291 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
# testing signal library to kill process

import subprocess, signal

p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)

out, err = p.communicate()

for line in out.splitlines():

    if 'thunderbird' in line:
     pid = int(line.split(None, 1)[0])
     os.kill(pid, signal.SIGKILL)