title: Check if a program has stopped working in Windows using python
body: <p>I am trying to create a python program that can detect if a particular program I use stops working so it can then notify me that it has stopped working.</p>
  <p>Currently, I have this:</p>
  <pre><code>def isresponding(name):
      os.system('tasklist /FI &quot;IMAGENAME eq %s&quot; /FI &quot;STATUS eq not responding&quot; &gt; tmp.txt' % name)
      tmp = open('tmp.txt', 'r')
      a = tmp.readlines()
      print(a)
      tmp.close()
      if a[-1].split()[0] == name:
          print(&quot;True&quot;)
          return True
      else:
          print(&quot;False&quot;)
          return False
  </code></pre>
  <p>The problem with this code is this it checks if the program is not responding however, my program gives this instead but doesn't say not responding</p>
  <p><a href="https://i.stack.imgur.com/SQLhu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SQLhu.png" alt="Image showing error" /></a></p>
  <p>Is there any way python that can detect if this happens or do I need to use something else?</p>
  <p>Any help would be appreciated.</p>