I am writing a Python script that requires the use of an executable that occasionally gets stuck in an infinite loop. When stuck in this loop, the executable spits out the same line of text to standard out. This I intend to catch and once I do, kill the executable. When I run this script manually I can just use CTRLC.
What is the correct way to programmatically kill off the executable from within the Python script? I am using Python 2.7, yet I am also curious as to the 3.x solution. I am using an os.system() call.