title: Is this the right way to terminate subprocess?
body: <p>I am using arecord through subprocess to record in raspberry pi : press joystick button to start recording and press button again to stop recording:  I use the p.terminate()  to stop recording, here is my code. i don't know if it is the right way to terminate subprocess?</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>if joystick.get_numbuttons() &gt;= 1 and joystick.get_button( 0 ) == 0 and    button_pressed:
  button_pressed = False
  is_recording = not is_recording
  print(is_recording)
  
  #start recording
  if is_recording:
      dotting = dotting + 1
      #recording code
     datetime.now().strftime("%Y%m%d_%H%M%S")
      filename = "%s.wav" % datetime.now().strftime("%Y%m%d_%H%M%S")
      p=subprocess.Popen(['arecord', '--device=hw:1,0', '--format', 'S16_LE', '--rate', '44100-c1', filename], shell=False)
  
      #change background
      background = pygame.image.load(background_image2).convert()
      #start timer
      stopFlag = Event()
      timer = MyTimer(stopFlag,time.clock())
      #timer.start()
      text2 = font.render('.', True, BLACK)
  
      screen.blit(background, (0,0))
  
      stopFlag.set()
  
      #record, remaining here
  
  
  #stop recording
  else:
      #stop recording, save record
      timer.do_run = False
      backToPreviousQuestion()
      background = pygame.image.load(background_image).convert()
      p.terminate()
  </code></pre>
  
  <p>pygame.display.update()</p>