Reputation: 657
I have a python application which is installed as a console_script on Windows.
I'd like the application to run as a background process for some time and then I would like to terminate it.
I start the process with:
START /B <application_name>
And try to terminate it with:
taskkill /PID <PID>
However when I try and terminate the process, without the force option, I get the error:
ERROR: The process with PID 17836 could not be terminated.
Reason: This process can only be terminated forcefully (with /F option).
Does anyone know how I should extend my Python application so that it can be terminated without the force option?
Not sure if it is important, but I noticed that starting the application actually creates two processes, a python.exe process which seems to be the parent process and the application process.
Upvotes: 1
Views: 734
Reputation: 657
I'm not sure if this does a 'clean' termination of the process, but I found using the /T
option for taskkill ensured that all parent and child processes are terminated as well which at least stopped the process.
Ultimately, the command becomes:
taskkill /T /F /PID <pid_number>
Upvotes: 1