I'm making a python program that should force kill the current program using pid. It is designed to be run with AHK. I am on windows 10.
I assigned "os.getpid()" to "pid" I have tried using the
os.kill(pid,signal.SIGKILL)
command to kill the pid of the program, but this command only works on Linux.
I found another viable solution, using the
os.system("taskkill /f /pid ")
command. My problem lies with this command. I cannot figure out how to format it to use the variable "pid" that I assigned eariler.
Here is my code:
import os
import signal
pid = os.getpid()
os.system("taskkill /f /pid" "pid")
This format did not work. I need help with the formatting of the "os.system("taskkill /f /pid" "pid") command. (i also tried "os.system("taskkill /f /pid" os.getpid()))
The code should have killed the python shell that I was using for testing. (but it didn't)