Skip to content

Commit eddf844

Browse files
aamCommit Queue
authored andcommitted
[infra] Clean up task killing on Windows.
Currently task_kill attempts to kill "No" process when no processes with given name are found. For example https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8725661622744325729/+/u/kill_processes__2_/stdout Follow-up to 86c3959 Change-Id: I7e76f2ad6351ede530f4d4b0760e47bfacb1476b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404722 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]>
1 parent 3394fec commit eddf844

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tools/task_kill.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,20 @@ def GetPidsPosix(process_name):
127127

128128

129129
def GetPidsWindows(process_name):
130-
cmd = 'tasklist /FI "IMAGENAME eq %s" /NH' % process_name
130+
cmd = 'tasklist /fo list /FI "IMAGENAME eq %s"' % process_name
131131
# Sample output:
132-
# dart.exe 4356 Console 1 6,800 K
132+
# Image Name: dart.exe
133+
# PID: 26568
134+
# Session Name: Console
135+
# Session#: 1
136+
# Mem Usage: 130,236 K
137+
#
138+
# Image Name: dart.exe
139+
# PID: 22424
140+
# Session Name: Console
141+
# Session#: 1
142+
# Mem Usage: 280,776 K
143+
133144
p = subprocess.Popen(cmd,
134145
stdout=subprocess.PIPE,
135146
stderr=subprocess.PIPE,
@@ -140,9 +151,9 @@ def GetPidsWindows(process_name):
140151
lines = output.splitlines()
141152

142153
for line in lines:
143-
split = line.split()
144-
if len(split) > 2:
145-
results.append(split[1])
154+
split = line.split(':')
155+
if (len(split) == 2) and (split[0].strip() == 'PID'):
156+
results.append(split[1].strip())
146157
return results
147158

148159

0 commit comments

Comments
 (0)