-1

I am trying to perform adb interactions through python code. I have an endless executable on the android device which i would like to start and after 10 seconds kill it. right now, i can get the program to start but cannot kill it other the manually pressing ctrl+c.

procID = subprocess.Popen(["adb", "shell"], stdin=subprocess.PIPE,)
procID.communicate('su\n endless_program data/test 5\n')
time.sleep(5)
os.kill(procID, signal.SIGINT)
procID.kill()

i tried killing it with os.kill or procID.kill but both don't seem to work.

I have also trying using pexpect, but for some reason i cant get it to run adb.

TamirE
  • 3
  • 2

1 Answers1

0

You are just killing the adb shell session, which won't kill the running application. If you would like to kill the running Android application, you have to stop the app over the adb shell. For details have a look at this stackoverflow answer.

Phidelux
  • 2,043
  • 1
  • 32
  • 50
  • Hi Phidelux, thanks for the quick reply. after running 'adb shell' and the 'endless program', the program outputs runs through the cmd window. Thus, i don't have any access to any adb commands untill i do ctrl+c. so even that adb shell session isn't terminated. Am I clear enough? – TamirE Sep 09 '16 at 18:41
  • Isn't it possible to start a second shell in order to kill the process blocking the first one? – Phidelux Sep 09 '16 at 18:45
  • hmmmm... interesting. I'll give it a try – TamirE Sep 09 '16 at 18:46