Merge pull request #111 from rxwen/fix_race_condition_in_getpid

Fix bug: may fail to get target pid
This commit is contained in:
Jake Wharton
2015-09-18 08:28:03 -04:00
+1 -1
View File
@@ -254,7 +254,7 @@ def tag_in_tags_regex(tag, tags):
ps_command = base_adb_command + ['shell', 'ps'] ps_command = base_adb_command + ['shell', 'ps']
ps_pid = subprocess.Popen(ps_command, stdin=PIPE, stdout=PIPE, stderr=PIPE) ps_pid = subprocess.Popen(ps_command, stdin=PIPE, stdout=PIPE, stderr=PIPE)
while ps_pid.poll() is None: while True:
try: try:
line = ps_pid.stdout.readline().decode('utf-8', 'replace').strip() line = ps_pid.stdout.readline().decode('utf-8', 'replace').strip()
except KeyboardInterrupt: except KeyboardInterrupt: