How to use subprocess
to terminate a program which is started at boot?
I ran across this question and found wordsforthewise's answer and tried it but nothing happens.
Wordsforthewise' Answer:
import subprocess as sp
extProc = sp.Popen(['python','myPyScript.py']) # runs myPyScript.py
status = sp.Popen.poll(extProc) # status should be 'None'
sp.Popen.terminate(extProc) # closes the process
status = sp.Popen.poll(extProc) # status should now be something other than 'None' ('1' in my testing)
I have a program /home/pi/Desktop/startUpPrograms/facedetection.py
running at boot by a Cronjob and I want to kill it from a flask app route like this.
Assigning program name to extProc = program_name
would work? If yes how to assign it?
@app.route("/killFD", methods=['GET', 'POST'])
def killFaceDetector():
#kill code goes here.