title: Gunicorn not able to kill an external process
body: <p>Hello I have a web application written in Flask which is attached to a USB credit card swiper. The code for the swiper is written in java and my flask app is something like this</p>
  
  <pre><code>@app.route("/swipe")
  def index():
      a = Popen(["sudo", "java", "sample"], shell=False)
      sts2 = os.waitpid(p.pid, 0)
      return "hello"
  
  
  @app.route("/kill_swiper", methods=["POST"])
  def index_2():
      try:
          pid = request.json
          pid = pid.get("pid")
          os.kill(int(pid), signal.SIGTERM)
          return Response(json.dumps({"status": True}), status=200, mimetype='application/json')
  
      except Exception as e:
          print(e)
          return Response(json.dumps({"status": False}),
                          status=417, mimetype='application/json')
  
  
  if __name__ == '__main__':
      app.config['TEMPLATES_AUTO_RELOAD'] = True
      app.run(host="0.0.0.0")
  </code></pre>
  
  <p>Whenever the user clicks a button the swiper will be triggered redirecting him to a page where he can either swipe card or click cancel.</p>
  
  <p>Coming to my problem, I am able to kill the swiper externally by running the command </p>
  
  <p><code>sudo kill &lt;pid of swiper&gt;</code></p>
  
  <p>But when I try to click the cancel button on the website, it is not getting killed. I am running the flask application behind <strong>gunicorn</strong> and I am using the following command to run gunicorn</p>
  
  <pre><code>sudo gunicorn --bind 0.0.0.0:5000 --workers 3 app:app
  </code></pre>
  
  <p>I tried giving threads as an option but it did not work. Can someone tell me where I am going wrong</p>