Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: third_party/psutil/examples/killall.py

Issue 8919026: Remove psutil from tree, install via install-build-deps.sh (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # $Id: killall.py 1143 2011-10-05 19:11:59Z g.rodola $
4 #
5 # Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
6 # Use of this source code is governed by a BSD-style license that can be
7 # found in the LICENSE file.
8
9 """
10 Kill a process by name.
11 """
12
13 import os
14 import sys
15 import psutil
16
17 def main():
18 if len(sys.argv) != 2:
19 sys.exit('usage: %s name' % __file__)
20 else:
21 NAME = sys.argv[1]
22
23 killed = []
24 for proc in psutil.process_iter():
25 if proc.name == NAME and proc.pid != os.getpid():
26 proc.kill()
27 killed.append(proc.pid)
28 if not killed:
29 sys.exit('%s: no process found' % NAME)
30 else:
31 sys.exit(0)
32
33 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698