title: How to stop airodump-ng subprocess in Python?
body: <p>What I am trying to do is record the output of airodump-ng every 10 seconds.</p>
  
  <p><strong>First attempt:</strong>
  Going through the airodump-ng <a href="https://www.aircrack-ng.org/doku.php?id=airodump-ng" rel="nofollow noreferrer">documentation</a> they mention such a command <code>--write-interval</code>
  When I tried using it:<code>sudo airodump-ng mon0 -w testOutput --write-interval 10 -o csv</code>, I got the error that <code>--write-interval</code> is an unrecognized option.</p>
  
  <p><strong>Second attempt:</strong>
  I tried doing this myself in Python. I then came accross the issue of trying to stop the process. The closest I got was <a href="https://stackoverflow.com/a/11377278/6351320">this solution</a>. </p>
  
  <pre><code>airodump = subprocess.Popen(['sudo', 'airodump-ng', 'mon0', '-w', 'pythonTest'], 
  stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  
  o_airodump, unused_stderr = airodump.communicate(timeout=15)
  airodump.kill()
  </code></pre>
  
  <p>This does stop the process, and I do have the relevant output files, BUT what happens is that all my running programs close and I get logged out of Ubuntu. </p>
  
  <p>Additional Info:</p>
  
  <p>Just before everything closes and I got logged out, I saw an error message on the terminal. I quickly screenshot it to see what it said:</p>
  
  <pre><code>Traceback (most recent call last):
    File "airodump-call.py", line 3, in &lt;module&gt; o_airodump, unused_stderr = airodump.communicate(timeout=15)
    File "/usr/lib/python3.5/subprocess.py", line 1072, in communicate stdout, stderr = self.communicate(input, endtime, timeout)
    File "usr/lib/python3.5/subprocess.py", line 1713, in _communicate raise TimeoutExpired(self.args, orig_timeout)
  subprocess.TimeoutExpired: Command '['airodump-ng', 'mon0', '-w', 'pythonTest']' timed out after 15 seconds
  </code></pre>