12345678910111213141516171819202122 |
- #! /usr/bin/env python3
- # -*- coding: utf-8 -*-
- import psutil
- def main():
- try:
- with open("pid", "r") as f:
- text = f.read().replace("\n", "").replace("\r", "")
- pid = int(text)
- with open("pid", "w") as f:
- f.write("")
- for proc in psutil.process_iter():
- if proc.pid == pid:
- proc.kill()
- except Exception as e:
- print(e)
- if __name__ == '__main__':
- main()
|