Skip to content

Commit

Permalink
[infra] Clean up task killing on Windows.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
aam authored and Commit Queue committed Jan 15, 2025
1 parent 3394fec commit eddf844
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tools/task_kill.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,20 @@ def GetPidsPosix(process_name):


def GetPidsWindows(process_name):
cmd = 'tasklist /FI "IMAGENAME eq %s" /NH' % process_name
cmd = 'tasklist /fo list /FI "IMAGENAME eq %s"' % process_name
# Sample output:
# dart.exe 4356 Console 1 6,800 K
# Image Name: dart.exe
# PID: 26568
# Session Name: Console
# Session#: 1
# Mem Usage: 130,236 K
#
# Image Name: dart.exe
# PID: 22424
# Session Name: Console
# Session#: 1
# Mem Usage: 280,776 K

p = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand All @@ -140,9 +151,9 @@ def GetPidsWindows(process_name):
lines = output.splitlines()

for line in lines:
split = line.split()
if len(split) > 2:
results.append(split[1])
split = line.split(':')
if (len(split) == 2) and (split[0].strip() == 'PID'):
results.append(split[1].strip())
return results


Expand Down

0 comments on commit eddf844

Please sign in to comment.